UNPKG

@muban/muban

Version:

Writing components for server-rendered HTML

10 lines (9 loc) 801 B
export declare type InjectionKey<T> = symbol; export declare function provide<T>(key: InjectionKey<T> | string, value: T): void; export declare function inject<T>(key: InjectionKey<T> | string): T | undefined; export declare function inject<T>(key: InjectionKey<T> | string, defaultValue: T, treatDefaultAsFactory?: false): T; export declare function inject<T>(key: InjectionKey<T> | string, defaultValue: T | (() => T), treatDefaultAsFactory: true): T; /** * Helper function around provide/inject to create a typed pair with a curried "key" and default values */ export declare function createContext<T>(key: InjectionKey<T> | string, defaultValue?: T): readonly [(value?: T | undefined) => void, (defaultInjectValue?: T | (() => T) | undefined, treatDefaultAsFactory?: boolean | undefined) => T];