Lift an async operation that accepts an AbortSignal into a Task.
Creates an internal AbortController and passes its signal to producer. If the resulting task is canceled or rejected externally, controller.abort() is called automatically.
producer
controller.abort()
returned task resolve type
factory function receiving an AbortSignal
task wrapping the operation
const fetchUser = (id: string) => Task.fromAbortSignal((signal) => fetch(`/api/users/${id}`, { signal }).then((res) => res.json()) ); Copy
const fetchUser = (id: string) => Task.fromAbortSignal((signal) => fetch(`/api/users/${id}`, { signal }).then((res) => res.json()) );
Lift an async operation that accepts an AbortSignal into a Task.
Creates an internal AbortController and passes its signal to
producer. If the resulting task is canceled or rejected externally,controller.abort()is called automatically.