-
Notifications
You must be signed in to change notification settings - Fork 9
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
cleanup(ts/hooks/useDetour): replace state
with snapshot from createDetourMachine
#2615
cleanup(ts/hooks/useDetour): replace state
with snapshot from createDetourMachine
#2615
Conversation
Coverage of commit
|
@@ -99,7 +99,7 @@ export const DiversionPage = ({ | |||
</header> | |||
|
|||
<div className="l-diversion-page__panel bg-light"> | |||
{state === DetourState.Edit && ( | |||
{snapshot.matches({ "Detour Drawing": "Editing" }) ? ( |
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.
Hmmm - I don't love this, because it leaks the state machine guts out of useDetour
and into diversionPage
. I like the (imperfect but improving) idea that useDetour
's role is to tell diversionPage
a bunch of facts about the detour (well, really the detour editing process) as it currently is, and I feel like calling xstate
methods directly strays away from that.
I know earlier I said that we should get rid of DetourState
, but having something at the level of EditScreen
/SharingScreen
(and eventually /RouteSelectionScreen
) feels like an appropriate thing for useDetour
to expose.
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 somewhat disagree because I see the state machine replacing useDetour
/useDetour
being a light wrapper around the state machine. I prefer this, because to me the state machines states should ideally match what we're trying to do in the UI, so it should read well to use the state machines states directly in the UI, and IMO, exposing extra states from useDetour
that the state machine is unaware of feels wrong in an anti-pattern type way (I could be wrong!), but I think that the state machine is enough of an enum
that I'd argue it's typesafe enough to be part of the public api of useDetour
and the UI
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 should keep chatting about this, but the new context is #2617
8daac43
to
b5c4503
Compare
c9f4c62
to
9dd609f
Compare
b5c4503
to
5fbfc26
Compare
9dd609f
to
0ba679d
Compare
Coverage of commit
|
Coverage of commit
|
0ba679d
to
588dcc8
Compare
5fbfc26
to
2cb4dbe
Compare
Uhh, I dunno what you just did github, but I did not merge this |
https://github.com/mbta/skate/pull/2607/files#r1608932364