@webshrine/vue
Advanced tools
Comparing version 0.0.11 to 0.0.12
{ | ||
"name": "@webshrine/vue", | ||
"type": "module", | ||
"version": "0.0.11", | ||
"version": "0.0.12", | ||
"description": "", | ||
@@ -24,4 +24,4 @@ "author": "", | ||
"@vueuse/core": "^12.0.0", | ||
"@webshrine/stdlib": "0.0.11", | ||
"@webshrine/stdtyp": "0.0.11", | ||
"@webshrine/stdlib": "0.0.12", | ||
"@webshrine/stdtyp": "0.0.12", | ||
"vue": "^3.5.13" | ||
@@ -28,0 +28,0 @@ }, |
@@ -1,2 +0,1 @@ | ||
/* eslint-disable jsdoc/require-jsdoc */ | ||
import type { InjectionKey } from 'vue' | ||
@@ -7,16 +6,27 @@ import type { UseAsyncReturn } from './useAsync' | ||
/** @category Composables */ | ||
type InjectableSource<T> = InjectionKey<T> | string | ||
/** @category Composables */ | ||
type AsyncSource<T> = Promise<T> | (() => Promise<T>) | ||
/** @category Composables */ | ||
type UseSource<T> = InjectableSource<T> | AsyncSource<T> | ||
/** @category Composables */ | ||
const isProvidableSource = <T>(source: UseSource<T>): source is InjectableSource<T> => { | ||
return typeof source === 'string' || typeof source === 'symbol' | ||
} | ||
/** @category Composables */ | ||
const isAsyncSource = <T>(source: UseSource<T>): source is AsyncSource<T> => | ||
typeof source === 'function' || source instanceof Promise | ||
/** @category Composables */ | ||
export function use<T>(source: InjectableSource<T>): T | undefined | ||
/** @category Composables */ | ||
export function use<T>(source: AsyncSource<T>, initialState: T): UseAsyncReturn<T, []> | ||
/** @category Composables */ | ||
export function use<T>(source: UseSource<T>, initialState?: T) { | ||
@@ -23,0 +33,0 @@ if (isProvidableSource(source)) { |
@@ -7,2 +7,3 @@ import type { MaybePromise } from '@webshrine/stdtyp' | ||
/** @category Composables */ | ||
export interface UseAsyncReturn<Data, Params extends any[]> { | ||
@@ -15,2 +16,3 @@ readonly value: Data | ||
/** @category Composables */ | ||
export type UseAsyncOptions<D = any> = { | ||
@@ -30,2 +32,3 @@ immediate?: boolean | ||
* A composable function that helps with managing async operations. | ||
* @category Composables | ||
*/ | ||
@@ -32,0 +35,0 @@ export function useAsync<Data, Params extends any[] = []>( |
/** @category Composables */ | ||
export function useBind() { | ||
// Your implementation here | ||
} |
@@ -1,5 +0,3 @@ | ||
/** | ||
* | ||
*/ | ||
/** @category Composables */ | ||
export function useCurrent() { | ||
} |
@@ -6,5 +6,9 @@ import type { AnyArrayOptional, AnyObject, Fn } from '@webshrine/stdtyp' | ||
/** @category Definers */ | ||
type ComposableInstance = AnyObject | ||
/** @category Definers */ | ||
type ComposableSetup = Fn<AnyArrayOptional, ComposableInstance> | ||
/** @category Definers */ | ||
interface DefineComposableOptions { | ||
@@ -21,2 +25,3 @@ | ||
/** @category Definers */ | ||
const flatter = <S extends DefineComposableOptions['setup']>(setup: S) => | ||
@@ -27,2 +32,3 @@ (...args: Parameters<S>) => reactive(setup(...args)) as UnwrapNestedRefs<ReturnType<S>> | ||
* Creates composable function with declarative control of behaviour. | ||
* @category Definers | ||
*/ | ||
@@ -29,0 +35,0 @@ export function defineComposable<O extends DefineComposableOptions>( |
import type { InjectionKey } from 'vue' | ||
import type { MaybePromise } from '../../../stdtyp/src/utilities' | ||
/** @category Types */ | ||
export type InjectableSource<T> = InjectionKey<T> | string | ||
/** @category Types */ | ||
export type AsyncSource<T> = Promise<T> | (() => MaybePromise<T>) |
11369
346