Mutation scenarios

See difficult dispatch rules in order.

Each scenario creates a fresh emitter, runs real module code, and compares the actual sequence with the documented sequence. No editable JavaScript or evaluation is involved.

Wildcard before typed

Wildcard subscribers receive the type and run before typed subscribers.

Expected: wildcard → typed

Not run.

Once before reentrant emit

The once record disappears before its handler publishes the same type again.

Expected: once → persistent:nested → persistent:outer

Not run.

Add during dispatch

The active registration array is live, so each newly appended handler can run in that emit.

Expected: first → second → late → first → second → late → late

Not run.

Remove before turn

A handler removed by an earlier peer is skipped immediately.

Expected: first

Not run.

Reset during dispatch

Reset replaces the registry. The active wildcard array finishes, then the old typed bucket is no longer found.

Expected: wildcard-reset → late-wildcard

Not run.

Synchronous throw

A synchronous handler error propagates and stops later handlers.

Expected: first → caught:expected

Not run.
These scenarios run without a bundler.

The page resolves the same bare package names through an import map. For an installed app, put this map before the first module script and serve the mapped files over HTTP(S):

<script type="importmap">
{"imports":{"event-pubsub":"./node_modules/event-pubsub/index.js","strong-type":"./node_modules/strong-type/index.js"}}
</script>

If the app uses a strict CSP, authorize the inline import-map script with an allowed nonce or hash.