Function: processableFamily()
processableFamily<
TInput,TNode>(build,options?):Family<TInput,TNode>
Defined in: packages/core/src/family.ts:256
Declare a family of Processables: one build function, members instantiated lazily and memoized per member key.
The build function receives the input plus the member's identity, so a composite can label itself the way a bot member does.
Give a key whenever the input is a whole domain object. Keying on the
object itself works only while every field is JSON-faithful, costs a full
serialisation per call, and makes two tickets that differ in a timestamp
two members. The id it belongs to is the thing that identifies it.
Type Parameters
TInput
TInput
TNode
TNode extends Processable<unknown, unknown>
Parameters
build
(input, identity) => TNode
options?
FamilyOptions<TInput>
Returns
Family<TInput, TNode>
Example
const reviewFor = processableFamily(
(ticket: Ticket) => pipeline(triage, assign, notify),
{ name: 'review', key: (ticket) => ticket.id },
);
const a = reviewFor(ticket);
reviewFor(ticket) === a; // memoized