import { NodeDefinition, NodeLike, StatefulGraphNode, StatefulNodeDefinition, StatefulNodeType } from '../../types/graph'; /** * An instance of the [[factory]] node. * See the [[factory]] documentation to find out more. */ export interface FactoryNode extends StatefulGraphNode<'factory', FactoryNodeProperties> { } /** * A definition of the [[factory]] node. * See the [[factory]] documentation to find out more. */ export interface FactoryNodeDefinition extends StatefulNodeDefinition<'factory', FactoryNodeProperties> { } export interface FactoryNodeProperties { factory: () => NodeDefinition; } export interface FactoryNodeState { instance: NodeDefinition; } export interface FactoryNodeData { } /** * The implementation of the [[factory]]. * See the [[factory]] documentation to learn more. */ export declare const FactoryNodeType: StatefulNodeType<'factory', FactoryNodeProperties, FactoryNodeState, FactoryNodeData>; /** * Creates a new instance of a [[factory]] node, which is a A type of [[NodeDefinition]] used when there's a need * to delay the creation of a node. The [[factory]] creates the instance of the node only when the application tries * resolving the [[factory]]. * * * @example **Using factory node** * ```js * import muster, { factory, ref, value } from '@dws/muster'; * * const app = muster({ * name: factory(() => { * console.log('Returning name'); * return value('Bob'); * }), * }); * * console.log('Retrieving name'); * const result = await app.resolve(ref('name')); * // result === 'Bob' * * // Console output: * // Retrieving name * // Returning name * ``` * This example shows how to use the [[factory]] to delay the time of the creation of a * particular node/branch. */ export declare function factory(factory: () => NodeLike | NodeDefinition): FactoryNodeDefinition; export declare function isFactoryNodeDefinition(value: NodeDefinition): value is FactoryNodeDefinition;