import React from "react"; import { ISvs, NOT_FOUND } from "./createSvs"; export declare type Wrapper = (children?: React.ReactNode) => React.ReactNode; export interface IScope { /** * Create a **child scope** of **this scope**. * Run the service in the **child scope**. * Put the service output in **this scope**. * The output will be visible by following services in this scope and the component subtree wrapped by `injectTo`. * * The "parent scope - child scope" structure will form a "enviroment tree" to resolve context requests properly. * It just works like enviroment model of most programing languages. */ useProvideSvs(svs: ISvs, ...input: Input): Output; /** * Create a **child scope** of **this scope**. * Run the service in the **child scope**. * Don't put the service output in **this scope**. */ useRunSvs(_svs: ISvs, ...input: Input): Output; /** * Find a service output from this scope, or its ancestor scope, or React context. */ useConsumeSvs(svs: ISvs): Output; useConsumeSvs(svs: ISvs, optional: boolean): Output | typeof NOT_FOUND; /** * Make the service outputs in this scope be visible by the wrapped JSX subtree. So that descendant components can consume them. * It takes a JSX tree, wrap it with React context provider, and return a new JSX tree that you should render. */ injectTo: Wrapper; /** * Create a child scope. * Finding a service output in a scope works like JS prototype chain. * You don't need to call this API manually in most cases. */ createChild(): IScope; } export declare class ScopeInternal implements IScope { private readonly parent; private readonly loaded; private _wrapper; constructor(parent?: ScopeInternal); private _useRunSvs; useRunSvs(_svs: ISvs, ...input: Input): Output; useProvideSvs(svs: ISvs, ...input: Input): Output; useConsumeSvs(svs: ISvs): Output; useConsumeSvs(svs: ISvs, optional: boolean): Output | typeof NOT_FOUND; private find; createChild(): ScopeInternal; get injectTo(): Wrapper; } export declare function useScope(): IScope; //# sourceMappingURL=Scope.d.ts.map