-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dcb99d8
commit 4dbabfe
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
'xstate': minor | ||
--- | ||
|
||
The `invoke.src` property now accepts an object that describes the invoke source with its `type` and other related metadata. This can be read from the `services` option in the `meta.src` argument: | ||
|
||
```js | ||
const machine = createMachine( | ||
{ | ||
initial: 'searching', | ||
states: { | ||
searching: { | ||
invoke: { | ||
src: { | ||
type: 'search', | ||
endpoint: 'example.com' | ||
} | ||
// ... | ||
} | ||
// ... | ||
} | ||
} | ||
}, | ||
{ | ||
services: { | ||
search: (context, event, { src }) => { | ||
console.log(src); | ||
// => { endpoint: 'example.com' } | ||
} | ||
} | ||
} | ||
); | ||
``` | ||
|
||
Specifying a string for `invoke.src` will continue to work the same; e.g., if `src: 'search'` was specified, this would be the same as `src: { type: 'search' }`. |