cefn / lauf

Monorepo for lauf packages.
MIT License
5 stars 0 forks source link

Provide a mechanism for early Selector-watching termination #179

Open cefn opened 2 years ago

cefn commented 2 years ago

When using signatures such as followSelector or withSelectorQueue the caller doesn't have an easy way to 'shut down' store activity.

For example, the store may be being terminated, and no future events should be triggered.

This is common within tests, but could also be needed within an SPA to fully terminate some state engine before starting another.

It is possible to provide this facility at the Store level (removing all watchers) or at the queue level (providing an abandonment handle which is waited on alongside queue.receive, allowing early termination rather than waiting for the next event to be able to resume control and exit the loop).

For example the launchEditEngine operation at https://github.com/cefn/notesome/blob/serve-components/modules/task-ui-frontend/src/engine.ts#L43 sets up a whole load of watchers, and it would be neat to be able to have a behaviour and maybe a flag status to close them down without stray events following on.