Replies: 5 comments
-
|
Beta Was this translation helpful? Give feedback.
-
Hey thanks for the quick response! Yes I realize the codesandbox is a very contrived example, but it illustrates well the steps that are problematic for my use case. I didn't know the state was being cached, this makes sense now. My use case is the following: on the entry of the initial state, I spawn a bunch of actors that are state machines as well. Since I am using client-side navigation for this site, the service (and all of its children services) is stopped when a user navigates to another page. If the user comes back to the page that has this machine, the service is restarted, but all the children services are not. I was expecting my assign action to be called to re-spawn them every time the initial state is entered, including when the service is restarted. I'm probably not using the right pattern. What do you think I should do in that case? |
Beta Was this translation helpful? Give feedback.
-
The use case sounds reasonable (spawning in the initial state) - could you prepare a new codesandbox presenting that problem? |
Beta Was this translation helpful? Give feedback.
-
Sure! Here, I updated the codesandbox to more accurately reflect what I'm going for. Obviously I left out a lot of code that is not necessary for the purpose of demonstrating this problem, but it should be clear. Let me know if you need more info. https://codesandbox.io/s/confident-pare-gq01s?file=/src/index.js Basically, I just need a way to restart my children services upon restarting the machine. Since an entry action is not working, I was thinking of sending an event at the start (like 'INIT') that would trigger an internal transition and perform the assign action. I don't really like this pattern since it requires an external intervention but that's what I've come up with so far. Haven't tested it yet. UPDATE: |
Beta Was this translation helpful? Give feedback.
-
Sorry I just realized this might not be the right place to ask this. Would you like me to start a discussion on the community forum instead and close the issue since this is not a bug? |
Beta Was this translation helpful? Give feedback.
-
Description
I have an entry action that assigns something to context on my initial state. Since I'm using client-side navigation, when a user navigates to another page, the service is stopped (handle by the framework I'm using). When I go back to the page, the service is started again, but my entry assign action is not getting called. Other entry actions are getting called, but no assign action.
Expected Result
Entry assign actions should be called whenever the state is entered, including when the service is restarted from a stopped state.
Actual Result
The entry assign action is not getting called when the service is restarted from a stopped state.
Reproduction
Here is an example of what I'm talking about. Look at the console logs and you can see that the entry assign action is not getting called when the service is restarted.
https://codesandbox.io/s/confident-pare-gq01s?file=/src/index.js
Beta Was this translation helpful? Give feedback.
All reactions