import type { Operation } from "./types.js"; /** * Create an * [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) * bound to the current scope. Whenever that scope is completed, * errored, or halted, the abort signal will be triggered. * * Cancellation and teardown is handled automatically in Effection, * but in systems where it is not, the lifespan of a transaction needs * to be explicitly modeled. A very common way to do this is with the * `AbortSignal`. By creating an abort signal bound to an Effection * scope, we can pass that signal down to 3rd party consumers that can * use it to register shutdown callbacks that will be invoked whenever * the task is done (either by completion, failure, or * cancellation). An example is the native * [`fetch()`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch#syntax) * API which takes a `signal` parameter in order to trigger when the * HTTP request should be cancelled. This is how you would bind the * lifetime of the HTTP request to the lifetime of the current task. * * @example * ```javascript * import { until, useAbortSignal } from 'effection'; * * function* fetchUser(id) { * let signal = yield* useAbortSignal(); * let response = yield* until(fetch(`/users/${id}`, { signal })); * * return yield* until(response.json()); * } * ``` * @since 3.0 */ export declare function useAbortSignal(): Operation;