Skip to content

packages/core/src/features/machines/callback.ts

Read as Markdown

This is the source snapshot used to build these API details. View this revision on GitHub.

Back to reference

1 import type { MachineEvent, MachineTask } from './types.js';
2 
3 /**
4  * Marks callback-style cancelable work as a machine task. The callback may return a cleanup;
5  * its cleanup runs exactly once when the owning state exits or the actor stops.
6  * @param callback - Callback task to retain as state-owned work.
7  * @returns The same callback, typed for an invocation's `task` field.
8  * @see {@link MachineTask}
9  */
10 export function fromCallback<Context, Event extends MachineEvent, Input>(
11   callback: MachineTask<Context, Event, Input>,
12 ): MachineTask<Context, Event, Input> {
13   return callback;
14 }
15 

Documentation built with @pibbl/core 0.0.2, revision 2dccb19. ALPHA — NOT FOR PRODUCTION USE.