import { ContextName, GraphNode, NodeDefinition, NodeLike, StatelessGraphNode, StatelessNodeDefinition, StatelessNodeType } from '../../types/graph'; /** * An instance of the [[withContext]] node. * See the [[withContext]] documentation to find out more. */ export interface WithContextNode extends StatelessGraphNode<'withContext', WithContextNodeProperties> { } /** * A definition of the [[withContext]] node. * See the [[withContext]] documentation to find out more. */ export interface WithContextNodeDefinition extends StatelessNodeDefinition<'withContext', WithContextNodeProperties> { } export interface WithContextNodeProperties { values: { [key in ContextName]: GraphNode | NodeDefinition; }; target: NodeDefinition; } /** * The implementation of the [[withContext]] node. * See the [[withContext]] documentation to learn more. */ export declare const WithContextNodeType: StatelessNodeType<'withContext', WithContextNodeProperties>; /** * Creates a new instance of a [[withContext]] node, which is used when there's a need of storing some data on the context. * Used internally by the [[hoistDependencies]] utility when sending the data to the remote muster * instance. * * * @example **Store and access data from context** * ```js * import muster, { computed, context, ref, value, withContext } from '@dws/muster'; * * const app = muster({ * inner: withContext({ * name: value('Bob'), * }, { * greeting: computed([context('name')], (name) => * `Hello, ${name}`, * ), * }), * }); * * const greeting = await app.resolve(ref('inner', 'greeting')); * // greeting === 'Hello, Bob'; * ``` * This example shows how to use the [[withContext]] to store data on the context and how * to access it with the help of the [[context]]. */ export declare function withContext(values: { [key in ContextName]: GraphNode | NodeDefinition; }, target: NodeDefinition | NodeLike): WithContextNodeDefinition; export declare function isWithContextNodeDefinition(value: NodeDefinition): value is WithContextNodeDefinition;