# packages/core/src/features/machines/callback.ts
This is the source snapshot used to build these API details. [View this revision on GitHub](https://github.com/benlesh/pibbl/blob/272a94aaf62e0bd6ad8726a4c607a76a9ec44ca1/packages/core/src/features/machines/callback.ts#L10).

[Back to reference](/reference/functions/machines/)

<pre class="api-source"><code><span id="L1"><a href="#L1" aria-label="Line 1">1</a> import type { MachineEvent, MachineTask } from './types.js';</span>
<span id="L2"><a href="#L2" aria-label="Line 2">2</a> </span>
<span id="L3"><a href="#L3" aria-label="Line 3">3</a> /**</span>
<span id="L4"><a href="#L4" aria-label="Line 4">4</a>  * Marks callback-style cancelable work as a machine task. The callback may return a cleanup;</span>
<span id="L5"><a href="#L5" aria-label="Line 5">5</a>  * its cleanup runs exactly once when the owning state exits or the actor stops.</span>
<span id="L6"><a href="#L6" aria-label="Line 6">6</a>  * @param callback - Callback task to retain as state-owned work.</span>
<span id="L7"><a href="#L7" aria-label="Line 7">7</a>  * @returns The same callback, typed for an invocation's `task` field.</span>
<span id="L8"><a href="#L8" aria-label="Line 8">8</a>  * @see {@link MachineTask}</span>
<span id="L9"><a href="#L9" aria-label="Line 9">9</a>  */</span>
<span id="L10"><a href="#L10" aria-label="Line 10">10</a> export function fromCallback&lt;Context, Event extends MachineEvent, Input&gt;(</span>
<span id="L11"><a href="#L11" aria-label="Line 11">11</a>   callback: MachineTask&lt;Context, Event, Input&gt;,</span>
<span id="L12"><a href="#L12" aria-label="Line 12">12</a> ): MachineTask&lt;Context, Event, Input&gt; {</span>
<span id="L13"><a href="#L13" aria-label="Line 13">13</a>   return callback;</span>
<span id="L14"><a href="#L14" aria-label="Line 14">14</a> }</span>
<span id="L15"><a href="#L15" aria-label="Line 15">15</a> </span></code></pre>

## Documentation version

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