import { GraphAction, GraphNode, NodeDefinition, NodeLike, StatefulGraphNode, StatefulNodeDefinition, StatefulNodeType } from '../../types/graph'; /** * An instance of the [[removeItems]] node. * See the [[removeItems]] documentation to find out more. */ export interface RemoveItemsNode extends StatefulGraphNode<'remove-items', RemoveItemsNodeProperties> { } /** * A definition of the [[removeItems]] node. * See the [[removeItems]] documentation to find out more. */ export interface RemoveItemsNodeDefinition extends StatefulNodeDefinition<'remove-items', RemoveItemsNodeProperties> { } export interface RemoveItemsNodeProperties { predicate: NodeDefinition; target: NodeDefinition; } export interface RemoveItemsNodeState { memoized: (targetNode: GraphNode, predicate: NodeDefinition) => GraphAction; } /** * The implementation of the [[removeItems]]. * See the [[removeItems]] documentation for more information. */ export declare const RemoveItemsNodeType: StatefulNodeType<'remove-items', RemoveItemsNodeProperties, RemoveItemsNodeState, {}>; /** * Creates an instance of a [[removeItems]] node, which is used to remove all items from a mutable * collection that match the provided predicate. * * The predicate can be any callable node (e.g. fn() or action() – the default is fn()), which will * be invoked with a single parameter (the list item), and must return a node that resolves to a * boolean value() node that determines whether to remove that item. The predicate will be invoked * once for each item in the collection. * * @example **Remove all items from a mutable collection that match the provided predicate** * ```js * import muster, { arrayList, entries, get, query, ref, removeItems, fn } from '@dws/muster'; * * const app = muster({ * tasks: arrayList([ * { description: 'First task', completed: true }, * { description: 'Second task', completed: true }, * { description: 'Third task', completed: false }, * ]), * }); * * app.resolve(query(ref('tasks'), entries({ description: true }))).subscribe((value) => { * console.log(value); * }); * * await app.resolve(removeItems(ref('tasks'), (item) => get(item, 'completed'))); * * // Console output: * // [{ description: 'First task' }, { description: 'Second task' }, { description: 'Third task' }] * // [{ description: 'Third task' }] * ``` */ export declare function removeItems(target: NodeDefinition, predicate: NodeDefinition | NodeLike | ((item: NodeDefinition) => NodeDefinition | NodeLike)): RemoveItemsNodeDefinition;