Examples
Async Chains
Three-module async chain: auth → permissions → dashboard, with configurable failure rates and retry.
Try it
Click “Start Chain” to begin. Adjust failure rate sliders to see error propagation and retry behavior. Each step only runs after its predecessor succeeds.
How it works
Three modules form an async chain using after ordering: auth validates the session, permissions loads after auth succeeds, and dashboard loads after permissions.
- after ordering –
loadPermissionsusesafter: ['auth::validateSession']to block until auth’s resolver settles;loadDashboardwaits for permissions the same way - crossModuleDeps – each step reads facts from its predecessor to check success (
auth.isValid,permissions.role) - Error propagation – if auth fails, permissions never evaluates (its
afterdependency is in rejected state), and dashboard is doubly blocked - Retry – auth uses
retry: { attempts: 2, backoff: 'exponential' }. Restarting auth automatically resumes the chain from where it left off
Summary
What: A three-step async chain (auth → permissions → dashboard) with configurable failure rates, retry with exponential backoff, and visual chain status.
How: Each module’s constraint uses after to depend on the previous step’s constraint, plus crossModuleDeps to read success state. The logging and devtools plugins trace the full chain execution.
Why it works: after provides hard ordering guarantees without manual promise chaining. Error propagation is automatic – downstream steps simply never evaluate when upstream fails. Retrying a single step resumes the entire chain.
Source code
// Source file "async-chains.ts" not found

