-
-
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.
* All tests pass! * Fix all tests * Some types cleanup * Fix types WIP * Add TODOs for types * Skip questionable test * Remove stray console logs * Add `spawn.machine` * Add `spawn.promise` * Add `spawn.observable` * Add tests for referenced behaviors * Revert "Add `spawn.observable`" This reverts commit 6df48b5. * Revert "Add `spawn.promise`" This reverts commit 9fce5a9. * Revert "Add `spawn.machine`" This reverts commit 0a3ac9f. * Cleanup * Temp fix for string references * Ignore excessive stack depth warnings * This actually passes * Remove invoke* * Rename createDeferredBehavior -> createCallbackBehavior * Make getContextAndActions private * Fix & clarify unskipped test * Add test from todo * Clean up test * Make parent "private" * Make sure children is "immutable" (+ todos) * Revert initialState change * Add comment * Oops * Remove invoke* functions (except for invokeMachine) * Quell 1 type error * Fixed the conditional type in the `interpret` * Bring back removed `spawn` type test * Tweak one `assign` test * Remove lazy argument from `createMachineBehavior` and remove `invokeMachine` entirely * Add a TODO comment about hiding `ActorRef["_parent"]` * Require a machine with all implementations provided as an argument for `createMachineBehavior` * Cache the `initialState` getter in `createMachineBehavior` * Unwrap `createCallbackBehavior` argument from a redundant lazy layer * Renaming WIP * Renaming WIP * Add back spawnBehavior but call it createActorRef * behaviors -> actors * Tweak tests * Remove Actor class * Remove actor.ts * Fix missing function * Remove createBehaviorFrom * Make behavior private * Add onEmit and remove complete * Tighten up types (a little) * Fix types * Remove createBehaviorFrom * No more magic events * Update packages/core/src/actors.ts Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> * Update packages/core/src/types.ts Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> * Fix types * Fix sendError (send raw error data, not events) * Attempt to fix type * Fix type * Rename onEmit -> onSnapshot * Rename types: TEmitted -> TSnapshot * Change src to allow behaviors directly (WIP) * Fix type errors * Add back InvokeSrcDefinition for now * Add fromEventObservable * Remove outdated `xstate/behaviors` references (#3280) * Avoid wrapping `behaviorImpl` in a throwaway function (#3281) * Update packages/core/test/actions.test.ts Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> * Update packages/xstate-svelte/src/useSelector.ts Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> * Update packages/xstate-svelte/src/useSelector.ts Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> * Update packages/xstate-vue/src/useSelector.ts Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> * Update packages/xstate-vue/src/useSelector.ts Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> * Remove unused type * Remove subscriptions from behaviors (they belong on ObservableActorRef only) * Add TODO * Remove unused type * Refactor: do not use observers for invoked promises * Remove latestData logic in interpreter * Remove observer logic from fromObservable/fromObservableEvent * Remove observers * Remove subscription logic from interpreter * Remove unused type * Fixed `ObservableActorRef` subscriptions and remove some outdated/redundant code (#3319) * Fixed `ObservableActorRef` subscriptions and remove some outdated/redundant code * Add changesets * Remove `createActorRef` * Make `Interpreter#nextState` pure again (#3340) * Rename `EmittedFrom` to `SnapshotFrom` (#3341) * Add changesets Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
- Loading branch information
1 parent
dc3eba3
commit 7a68cbb
Showing
73 changed files
with
2,425 additions
and
2,408 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,5 @@ | ||
--- | ||
'xstate': minor | ||
--- | ||
|
||
`onSnapshot` is now available for invoke configs. You can specify a transition there to be taken when a snapshot of an invoked actor gets updated. It works similarly to `onDone`/`onError`. |
This file was deleted.
Oops, something went wrong.
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,5 @@ | ||
--- | ||
'@xstate/vue': major | ||
--- | ||
|
||
Removed `getSnapshot` parameter from composables. It is expected that the received `actorRef` has to have a `getSnapshot` method on it that can be used internally. |
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,20 @@ | ||
--- | ||
'xstate': major | ||
--- | ||
|
||
`spawn` is no longer importable from `xstate`. Instead you get it in `assign` like this: | ||
|
||
```js | ||
assign((ctx, ev, { spawn }) => { | ||
return { | ||
...ctx, | ||
actorRef: spawn(promiseActor) | ||
}; | ||
}); | ||
``` | ||
|
||
In addition to that, you can now `spawn` actors defined in your implementations object, in the same way that you were already able to do that with `invoke`. To do that just reference the defined actor like this: | ||
|
||
```js | ||
spawn('promiseActor'); | ||
``` |
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,5 @@ | ||
--- | ||
'xstate': major | ||
--- | ||
|
||
`EmittedFrom` type helper has been renamed to `SnapshotFrom`. |
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
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,34 @@ | ||
--- | ||
'xstate': major | ||
--- | ||
|
||
The `services` option passed as the second argument to `createMachine(config, options)` is renamed to `actors`. Each value in `actors` should be a function that takes in `context` and `event` and returns a [behavior](TODO: link) for an actor. The provided behavior creators are: | ||
|
||
- `fromMachine` | ||
- `fromPromise` | ||
- `fromCallback` | ||
- `fromObservable` | ||
- `fromEventObservable` | ||
|
||
```diff | ||
import { createMachine } from 'xstate'; | ||
+import { fromPromise } from 'xstate/actors'; | ||
|
||
const machine = createMachine( | ||
{ | ||
// ... | ||
invoke: { | ||
src: 'fetchFromAPI' | ||
} | ||
}, | ||
{ | ||
- services: { | ||
+ actors: { | ||
- fetchFromAPI: (context, event) => { | ||
+ fetchFromAPI: (context, event) => fromPromise(() => { | ||
// ... (return a promise) | ||
}) | ||
} | ||
} | ||
); | ||
``` |
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,5 @@ | ||
--- | ||
'@xstate/react': major | ||
--- | ||
|
||
Removed `getSnapshot` parameter from hooks. It is expected that the received `actorRef` has to have a `getSnapshot` method on it that can be used internally. |
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
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
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,4 @@ | ||
{ | ||
"main": "dist/xstate-actors.cjs.js", | ||
"module": "dist/xstate-actors.esm.js" | ||
} |
This file was deleted.
Oops, something went wrong.
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
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
Oops, something went wrong.