asyncsignal
v1.0.1
Published
Reusable asynchronous signals,it's a like promisewithResolvers
Maintainers
Readme
AsyncSignal
Reusable async signals and a data loader .
- 📚 Documentation: https://zhangfisher.github.io/asyncsignal/
- 🔢 npm: asyncsignal
Overview
AsyncSignal provides two complementary building blocks for asynchronous operations:
asyncSignal— a reusable async signal. LikePromise.withResolvers(), but resettable, observable, and abort-aware. Suited for event waiting, timeout control, and manual completion.AsyncLoader— an async data loader built on top ofasyncSignal. Encapsulates the full loading lifecycle: load + cache + abort + timeout + retry + multiplexing + error fallback + multi-loader.
Features
asyncSignal
- Manual
resolve/reject/reset— reusable across multiple waits - Static
asyncSignal.resolve()/asyncSignal.reject()for pre-settled signals - Wait timeout,
untilconstraints, and auto-reset - Native
AbortControllerintegration with configurableabortAtbehavior - Status queries (
isPending/isFulfilled/isRejected),result/error/timestamp, and typed metadata
AsyncLoader
- Auto / lazy loading, per-attempt timeout, and automatic retry
- Hash-based caching with pluggable storage
abort()penetrating to the underlying request (fetchsignalready)- Multiplexing (
off/restart/share) to deduplicate concurrent or repeated loads - Error fallback (
defaultValue) - Multi-loader orchestration —
fallbackfailover (switch to backup on failure) andcombinemulti-source merge (concurrent loads aggregated viaonResults)
Installation
# pnpm
pnpm add asyncsignal
# npm
npm install asyncsignal
# yarn
yarn add asyncsignal
# bun
bun add asyncsignalPackage entry points — main entry
asyncsignalships only theasyncSignalsignal part (lighter); the subpathasyncsignal/loaderincludes everything (asyncSignal+AsyncLoader).
Guide
Full guide and API reference at the official site:
👉 https://zhangfisher.github.io/asyncsignal/
License
MIT
