Skip to content
This repository has been archived by the owner on Mar 1, 2023. It is now read-only.

New Feature Idea 💡 - Reset the Machine #39

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

bemayr
Copy link
Contributor

@bemayr bemayr commented Apr 27, 2021

After working with the Catalogue quite a bit I encountered some situations where I wanted to reset the state machine. If I am the only one not being satisfied by hitting F5 in this case then please ignore and close this PR 😉!

During research on how to implement this I stumbled upon @mattpocock's comment regarding this on discord asking what is the best way to restart a service.

Implementing took a little while because of statelyai/xstate#2084, which (1) has a workaround for now (that's the initial empty contexts) and (2) will be integrated in an upcoming version of @xstate/react.

@vercel
Copy link

vercel bot commented Apr 27, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/mattpocock/xstate-catalogue/BoaNfJLf3FA6CzTEddPmgRySRpmG
✅ Preview: https://xstate-catalog-git-fork-bemayr-feature-reset-machine-mat-abcacc.vercel.app

@bemayr
Copy link
Contributor Author

bemayr commented Apr 27, 2021

I've got three [two] comments regarding the code:

  1. I am not 100% happy with the inspector/start and stop service part of the code, if somebody has an idea on how to improve this I would be more than glad! 😊
  2. And the way this works now, examples with a random initial state (like Create / Update Form) do not receive a new initial state when hitting reset. The reason for this is that the machines are passed down via props and created using createMachine(...) somewhere else. Any thoughts on this?
  3. Feel free to change anything about the placement/design of the Reset Machine Button! 💅

@mattpocock
Copy link
Owner

@bemayr Good idea! This is for sure an important feature.

I'm not seeing it working on this link:

https://xstate-catalog-git-fork-bemayr-feature-reset-machine-mat-abcacc.vercel.app/machines/form-input

Will take a look at the code at some point, on my todo list

@bemayr
Copy link
Contributor Author

bemayr commented May 11, 2021

Thanks for your answer Matt and looking into this!

I'm not seeing it working on this link:
https://xstate-catalog-git-fork-bemayr-feature-reset-machine-mat-abcacc.vercel.app/machines/form-input

What exactly is not working for you there? Because for me the button is there and it resets the machine...? 🤔

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants