AsyncSignal

July 5, 2026 Β· View on GitHub

Reusable async signals and a data loader .

δΈ­ζ–‡

Overview

AsyncSignal provides two complementary building blocks for asynchronous operations:

  • asyncSignal β€” a reusable async signal. Like Promise.withResolvers(), but resettable, observable, and abort-aware. Suited for event waiting, timeout control, and manual completion.
  • AsyncLoader β€” an async data loader built on top of asyncSignal. 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, until constraints, and auto-reset
  • Native AbortController integration with configurable abortAt behavior
  • 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 (fetch signal ready)
  • Multiplexing (off / restart / share) to deduplicate concurrent or repeated loads
  • Error fallback (defaultValue)
  • Multi-loader orchestration β€” fallback failover (switch to backup on failure) and combine multi-source merge (concurrent loads aggregated via onResults)

Installation

# pnpm
pnpm add asyncsignal
# npm
npm install asyncsignal
# yarn
yarn add asyncsignal
# bun
bun add asyncsignal

Package entry points β€” main entry asyncsignal ships only the asyncSignal signal part (lighter); the subpath asyncsignal/loader includes everything (asyncSignal + AsyncLoader).

Guide

Full guide and API reference at the official site:

πŸ‘‰ https://zhangfisher.github.io/asyncsignal/

License

MIT