Skip to content

Proposal: explicit DSL API to cancel pending dispatches #166

@hkusu

Description

@hkusu

Summary

Introduce an explicit API in the Store {} DSL to cancel pending/queued dispatches from inside handlers.

This is an alternative (or complement) to policy-based behavior discussed in #164.

Motivation

In some flows, the app should explicitly discard already-queued actions at a specific point (for example, after reaching a terminal state or after handling a one-shot action).

A local, explicit DSL call can be easier to reason about than only having a global queue policy.

Proposal

Add a function available from relevant DSL scopes:

  • Preferred name: cancelPendingActions()
  • Alternative names: cancelQueuedDispatches(), clearActionQueue()

Example

state<MyState.Active> {
    action<MyAction.Finish> {
        cancelPendingActions()
        nextState(MyState.Done)
    }
}

Relationship to #164

Both approaches could be implemented independently or combined.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions