Skip to content

Commit

Permalink
Merge pull request #1666 from davidkpiano/changeset-release/master
Browse files Browse the repository at this point in the history
Version Packages
  • Loading branch information
davidkpiano authored Nov 28, 2020
2 parents 1413bc3 + afcade3 commit 80ea4ba
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 48 deletions.
47 changes: 0 additions & 47 deletions .changeset/poor-bugs-reflect.md

This file was deleted.

48 changes: 48 additions & 0 deletions packages/xstate-graph/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,53 @@
# @xstate/graph

## 1.3.0

### Minor Changes

- [`111a7d13`](https://github.com/davidkpiano/xstate/commit/111a7d138db909e969629a3c237b952850c008ca) [#1663](https://github.com/davidkpiano/xstate/pull/1663) Thanks [@davidkpiano](https://github.com/davidkpiano)! - Options passed into graph functions (e.g., `getShortestPaths(machine, options)`) can now resolve `.events` based on the `state`:

```js
const countMachine = createMachine({
initial: 'active',
context: {
count: 0
},
states: {
active: {
on: {
ADD: {
actions: assign({
count: (context, event) => {
return context.count + event.value;
}
})
}
}
}
}
});

const shortestPaths = getShortestPaths(countMachine, {
events: {
ADD: state => {
// contrived example: if `context.count` is >= 10, increment by 10
return state.context.count >= 10
? [{ type: 'ADD', value: 10 }]
: [{ type: 'ADD', value: 1 }];
}
}
});

// The keys to the shortest paths will look like:
// "active" | { count: 0 }
// "active" | { count: 1 }
// "active" | { count: 2 }
// ...
// "active" | { count: 10 }
// "active" | { count: 20 }
// "active" | { count: 30 }
```

## 1.2.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/xstate-graph/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@xstate/graph",
"version": "1.2.0",
"version": "1.3.0",
"description": "XState graph utilities",
"keywords": [
"state",
Expand Down

0 comments on commit 80ea4ba

Please sign in to comment.