-
Notifications
You must be signed in to change notification settings - Fork 121
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
[POC] Refactor startup to a finite state machine #2130
Conversation
There's definitely potential in using the xstate lib for reducing complexity. And having it generate the transition diagrams is really nice. I can see how using it can simplify the important bit in this PR (the GetStarted index page), so I believe the approach is sound. However I have a few things to point out.
|
Thanks for reviewing my PR. Actually I drew this diagram using https://www.draw.io/ about your comments:
|
199756f
to
edd0994
Compare
I removed context and moved most the logic to the state machine and the code looks cleaner, indeed. I believe it still has some code to touch, and this PR will get too big. I can create a branch on my fork, so we can merge this refactors so we don't end with a huge diff. What do you think? |
The end result seems reasonable enough for now, I don't think you need to merge into a staging branch. |
I am fine by merging here directly. My only concern is that it will break the others startup method till the refactor is finished |
Is wallet removal and creation supposed to be broken on this (and on the following PR)? Just asking because I'm testing it out. The code is fine by itself. |
I fixed the wallet removal. Wallet creation I will fix at #2167 because it is a new state at choosing wallet. I am also going to update the state machine diagram. |
This seems gtg (with the caveat of the broken workflows) so we need to discuss with @alexlyp whether we want this merged right now or only after finishing all the other outstanding work in other PRs. |
The problem with having many open PRs at the same time, is that we will have many conflicts when starting merge them. There is a branch It will only need to rebase against master and I can re-open this PR against it. I think it is better then breaking the startup workflow. |
So issue being, since there are some outstanding PRs, this will cause conflicts on all of those? |
No, it probably doesn't have many conflicts with the outstandings PRs. The problem is that I believe it will have some PR to be implemented until all the refactor being completed. It already has #2167 implemented against this one, and still have the regular mode and spv mode to be implemented. |
65fc8fe
to
ef1b94a
Compare
closing because of #2177 |
This PR is a proposal to closes #2121
it is built on top of #2129.
right now our
getStartedPage
is a bunch ofif
andelse
which makes it really complicated to read and understand the logic behind it.This PR switches how decrediton starts to use a finite state machine instead of
if
andelse
.Right now it only works on advanced mode -> remote, and if approved I will conclude the other methods.
This is the finite state machine diagram I am building:
And this is the machine state repo I am using: https://github.com/davidkpiano/xstate
I am also adding context which was added at react 16.3: https://reactjs.org/docs/context.html so we don't need to pass props all the way down to others components.
If this gets approved, we can also use this concept to refactor how we are fetching our data. On this part of the doc there is an example of a fetch machine: https://xstate.js.org/docs/guides/states.html#state-meta-data
and with that we would not need to use isLoading all the time, as it is right now, but we can discuss this further on #1558