Metakit / @doeixd/metakit/machine
compose
function · packages/metakit/src/machine.ts:319
function compose<
S extends Schema.Top,
Own extends Readonly<Record<string, AnyTransition<S['Type']>>>,
Children extends Parts<S['Type']> = {},
Lazy extends Readonly<
Record<
string,
() => Promise<
| LazyMachineLike<S['Type']>
| {
readonly default: LazyMachineLike<S['Type']>
}
>
>
> = Readonly<Record<string, never>>,
>(
config: {
readonly state: S
readonly transitions: Own
readonly children?: Children | undefined
readonly lazyChildren?: Lazy | undefined
} & ([SharedTags<Own, Children>] extends [never]
? unknown
: {
readonly 'Machine.compose: two transitions share this tag': SharedTags<
Own,
Children
>
}),
): Machine<S['Type'], Arms<Composed<Own, Children>>> & {
readonly lazyChildren: {
readonly [K in keyof Lazy & string]: LazyChild<
S['Type'],
Extract<LazyChildResult<Lazy[K]>, LazyMachineLike<S['Type']>>
>
}
}