Overview
ZeroPromise<T> is a Promise you can cancel. It starts active, then settles to resolved, rejected, or cancelled. .signal is an AbortSignal. await, .then, .catch, and .finally work like a normal Promise.
Get, Post, Put, Patch, Delete, and Fetch return a ZeroPromise. Call .cancel() on that handle to abort the request.
asyncAtom passes the current run as { zero }. Pass zero.signal into fetch. asyncAction and taskAction watch a ZeroPromise you return: their cancel() / stop() call .cancel() on it. They recognize it by __isZeroPromise__.
ZeroPromise vs Promise
|
API
|
Cancel
|
State
|
|---|---|---|
Promise
| No built-in cancel | Settles once; no AbortSignal. |
ZeroPromise
|
.cancel() + .signal
|
isActive / isResolved / isRejected / isCancelled.
|
Resolve vs cancel
Start a 2s ZeroPromise, then cancel before it resolves. Status tracks active / resolved / cancelled.
AbortSignal + fetch
Pass zero.signal into fetch. Cancel aborts the network request.
Cancel a Get()
HTTP helpers already return a ZeroPromise. cancel() aborts that request with AbortError.