menu

Statecharts

Statecharts are a precise, visual way of modeling the behaviour of complex reactive systems. They describe how things work, and can help you get your code doing exactly what you want.

Channels
Team
Posts
Members
Info

Difference between `Interpreter.subscribe` and `Interpreter.onTransition`

Dumb question: What’s the difference between the subscribe and onTransition methods on an Interpreter? I’m missing something fundamental.

thumbsup
0
message-simple
0

Sending data from parent machine to child invoked callback

I'm basing my code on this section: https://xstate.js.org/docs/guides/communication.html#listening-to-parent-events However, when sending the events PING and PONG, is there any way I can send some other data along? If not, what's the best way to send data from parent machine to…

thumbsup
0
message-simple
2

Trying to update the context of a parent machine from an actor's context

CODESANDBOX REFERENCE: https://codesandbox.io/s/recipemachine-bikxx Hey everyone, I have two machines - one parent and one child - that I'm trying to get to communicate with one another. Specifically, I'd like for the child machine to periodically send an update/event to it's…

thumbsup
0
message-simple
2

What are some approaches to decouple xstate's state from component state?

I got to thinking about this over the weekend. We're starting to use XState much more heavily at work, and being able to refactor machines aggressively without having to touch components sounds nice. Off the top of my head, the only one I can think of is: • Build the equivalent…

thumbsup
6
message-simple
13

Opening UI Elements from anywhere in the app

https://codesandbox.io/embed/xstate-todomvc-33wr94qv1?from-embed In the TodoMVC Demo Application that uses the Actor Model, todosMachine spawns todoMachine(s). One is the direct parent of the other. Now consider a modal that would ideally be accessible from anywhere in the…

thumbsup
0
message-simple
9

@davidkpiano's article on Redux @ dev.to

@davidkpiano -- Just read your article on dev.to, great article! The following is a great example of realizing you need a state machine, trying to solve it via brute force, and abandoning it for XState. Hopefully, it will give you a chuckle... It hit home for me because I had…

thumbsup
2
message-simple
1

Drawing statecharts

Do you know of any statechart app I can use to draw statecharts? I'm thinking of something like https://www.draw.io/ but perhaps more specific, as draw.io seems to be a generic solution for flowcharts and UML. Thanks!

thumbsup
0
message-simple
5

How to reset history when machine transition into a specific state?

I have a machine https://xstate.js.org/viz/?gist=3bf02d060f5a5243fa6b11c9b5f382b1 I want to reset state b history when state transition into state a Would it be possible?

thumbsup
0
message-simple
2

Stored/serialized then reloaded states lose their actions' implementation?

If I save a serialized state and then try to restart a machine with this state - following the documentation, I do a state = State.create(reloadedState); and then resolvedState = myMachine.resolveState(state); and then …

thumbsup
0
message-simple
4

Nested actors with TypeScript

Hey, I'm having trouble adding TypeSript to Machines that are using Actors. I tried to replicate my issue in following CodeSandbox. https://codesandbox.io/embed/statemachine-with-typescript-uvg40 The problem in my code happened in the parentMachine when spawning a new child…

thumbsup
0
message-simple
2