|
|
@ -2,8 +2,9 @@ import type { InjectionKey } from 'vue' |
|
|
|
|
|
|
|
|
|
|
|
export function useInjectionState<Arguments extends any[], Return>( |
|
|
|
export function useInjectionState<Arguments extends any[], Return>( |
|
|
|
composable: (...args: Arguments) => Return, |
|
|
|
composable: (...args: Arguments) => Return, |
|
|
|
|
|
|
|
keyName = 'InjectionState', |
|
|
|
): readonly [useProvidingState: (...args: Arguments) => void, useInjectedState: () => Return | undefined] { |
|
|
|
): readonly [useProvidingState: (...args: Arguments) => void, useInjectedState: () => Return | undefined] { |
|
|
|
const key: string | InjectionKey<Return> = Symbol('InjectionState') |
|
|
|
const key: string | InjectionKey<Return> = Symbol(keyName) |
|
|
|
|
|
|
|
|
|
|
|
const useProvidingState = (...args: Arguments) => { |
|
|
|
const useProvidingState = (...args: Arguments) => { |
|
|
|
const providedState = composable(...args) |
|
|
|
const providedState = composable(...args) |
|
|
|