interface UseContext { /** * Get the current context. Throws if no context is set. */ use: () => T; /** * Get the current context. Returns `null` when no context is set. */ tryUse: () => T | null; /** * Set the context as Singleton Pattern. */ set: (instance?: T, replace?: Boolean) => void; /** * Clear current context. */ unset: () => void; /** * Exclude a synchronous function with the provided context. */ call: (instance: T, callback: () => R) => R; /** * Exclude an asynchronous function with the provided context. * Requires installing the transform plugin to work properly. */ callAsync: (instance: T, callback: () => R | Promise) => Promise; } declare function createContext(): UseContext; interface ContextNamespace { get: (key: string) => UseContext; } declare function createNamespace(): { get(key: any): UseContext; }; declare const defaultNamespace: ContextNamespace; declare const getContext: (key: string) => UseContext; declare const useContext: (key: string) => () => T; type AsyncFunction = () => Promise; declare function executeAsync(function_: AsyncFunction): [Promise, () => void]; declare function withAsyncContext(function_: AsyncFunction, transformed?: boolean): AsyncFunction; export { ContextNamespace, UseContext, createContext, createNamespace, defaultNamespace, executeAsync, getContext, useContext, withAsyncContext };