Skip to content

Commit

Permalink
Add changeset about conditional actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Andarist committed Mar 22, 2020
1 parent c390771 commit 6c47b66
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .changeset/good-countries-cross.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
'xstate': minor
---

Added support for conditional actions. It's possible now to have actions executed based on conditions using following:

```js
entry: [
decide([
{ cond: ctx => ctx > 100, actions: raise('TOGGLE') },
{
cond: 'hasMagicBottle',
actions: [assign(ctx => ({ counter: ctx.counter + 1 }))]
},
{ actions: ['fallbackAction'] }
])
];
```

It works very similar to the if-else syntax where only the first matched condition is causing associated actions to be executed and the last ones can be unconditional (serving as a general fallback, just like else branch).

0 comments on commit 6c47b66

Please sign in to comment.