You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -418,19 +418,21 @@ This pattern lets your *Store* react to external data changes automatically, suc
418
418
Coroutines started by `launch{}` are automatically cancelled when the *State* changes to a different *State*, making it easy to manage resources and subscriptions.
419
419
In `action{}`, `launch{}` is tied to the *State* active at action start.
420
420
421
-
### Cancel Pending Actions
421
+
### Clear Pending Actions
422
422
423
-
If you need to discard already queued `dispatch()` calls at a specific point, call `cancelPendingActions()` inside `enter{}`, `action{}`, `exit{}`, `error{}`, or inside `transaction{}` from a launched coroutine.
423
+
By default, Tart clears already queued actions when the store exits the current state and enters a different state variant.
424
+
To keep queued actions across state exits, set `pendingActionPolicy(PendingActionPolicy.KEEP)`.
424
425
425
426
```kt
426
-
state<MyState.Active> {
427
-
action<MyAction.Finish> {
428
-
cancelPendingActions()
429
-
nextState(MyState.Done)
430
-
}
427
+
val store = Store<MyState, MyAction, MyEvent>(MyState.Initial) {
428
+
// ...
429
+
430
+
pendingActionPolicy(PendingActionPolicy.KEEP)
431
431
}
432
432
```
433
433
434
+
Regardless of the configured `PendingActionPolicy`, you can still discard already queued actions at a specific point by calling `clearPendingActions()` inside `enter{}`, `action{}`, `exit{}`, `error{}`, or inside `transaction{}` from a launched coroutine.
435
+
434
436
### Alternative DSL Forms
435
437
436
438
Some DSL APIs are just alternative forms of existing APIs:
0 commit comments