-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[v5] Interpret all behaviors #3455
Conversation
🦋 Changeset detectedLatest commit: fc3ca72 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit fc3ca72:
|
👇 Click on the image for a new way to code review
Legend |
|
Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
public getStatus(state: State<TContext, TEvent, TResolvedTypesMeta>) { | ||
return state.done | ||
? { status: 'done', data: state.output } | ||
: { status: 'active' }; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably need an extra error
status for cases when something throws an error and we "forcefully" stop the machine (and notify subscribers about the error
)
Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
@@ -2,30 +2,18 @@ import type { | |||
InvokeCallback, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of this is in the actors.ts
but we refer to them as behaviors. It feels like we should do something about it because it feels like we are getting lost ourselves in the used nomenclature
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll do this in a separate PR (want to rename to behaviors.ts
because it's a noisy change
|
* Remove a custom `done` callback from the `Observer` * Spike removing the leftover dependencies on done listeners
…lyai/xstate into v5/interpret-all-behaviors
We're getting close! |
* Simplify function signature of `interpreter.send(eventObj)` * Remove unused types * Add changeset * Cleanup types * Simplify more event-related methods and functions (#3570) * Add changeset for `@xstate/fsm` * Fix tests Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
* Test cleanup * Committing this just to checkpoint it * Add status, change Actorcontext.exec sig * Actions resolve to tuple * Declassify ExeuctableAction * Goodbye ExecutableAction * Goodbye exec.ts * Refactor createDynamicAction * More refactoring * Yay more deleting * More refactoring * exectute2 -> execute * Enable root initial actions (addresses #466) * Working through types * Still working on types * Sorry, getting a little messy again * Revert "Sorry, getting a little messy again" This reverts commit a609de8. * Fix test * Ensure no side-effects in getInitialState * I guess this makes sense * Started state should come from behavior.start if it exists * Get rid of state-specific stuff * Remove test * Update packages/core/test/predictableExec.test.ts Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> * Refactor test * Update packages/core/test/actions.test.ts Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> * Update packages/core/test/actions.test.ts Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> * Update packages/core/test/predictableExec.test.ts Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> * Remove unused import * Update packages/core/test/actions.test.ts Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> * Update packages/core/test/actions.test.ts Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> * Interpreter tests * Remove unused `ActorContext['exec']` (#3734) * Fixed initial state cache eviction in the `Interpreter` (#3733) * Tweak logic around stopping actors (#3737) * Tweak logic around stopping actors * remove unused imports * Reuse the `ActorStatus` enum in the `handleAction` * Tweak types * Free the stopped `sessionId` in the registry * Make `getInitialState` in the `Interpreter` private (#3738) * Update packages/core/test/interpreter.test.ts Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> * Update packages/core/src/stateUtils.ts * Small cleanup of internal implementations of actors (#3740) * Small cleanup of internal implementations of actors * Remove redundant completion notifications sent out by some actors * Wrap sending `xstate.snapshot.${id}` events with `defer` * Drop the unused "next" case from the event observable Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
The biggest changes:
is removedObservableActorRef
interpret
now works with anyBehavior
:interpret(behavior)
Behavior
interface now hasBehavior.getSnapshot
, which is important for determining which "state" should be exposed, and which state is internal statepredictableActionArguments
flag is removed;actorCtx.exec
is used insteadInterpreter
; still have some more work to do here