Declarative scheduler for the event loop
Technically, a multi-state dependency graph, allows for declarative modeling of the control flow based on states interconnected by relations. Activating a state triggers a two-pass transition - negotiation and set. If a state change is triggered during an ongoing transition, it's gonna be queued (non-synchronous). Each state has a clock distinguishing state's instances (eg prevents the double callback execution problem).
npm install asyncmachine
Example order of listeners during a transition between states A and B. All methods (and events) with these names will be called.