-
|
Please consider a scenario where one workflow renders a screen (A) that in turn has a backstack of screens (B and C). The root workflow renders A and handles its outputs accordingly. This is all fine, until I decide to make life complicated by allowing the parent workflows to control which screen A starts at, and whether it should be able show screen B at all. Now Ive ended up in a situation where A:s outputs involve B:s outputs, despite it in some scenarios never rendering B at all. I know that this is the case, so when Root renders A, I can simply do "when output is from B, ignore it because it will never happen" but that seems very bad to do in a large codebase with multiple coders. How would you approach this? My thought so far:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
|
It's such an abstract framing that I'm having a difficult time answering. Maybe you could reply with the real names of Root, A, B and C and their outputs? A few thoughts that do occur to me:
I would throw in a situation like that. Rather than, "ignore it because it will never happen," throw because "uh oh, this should never happen!" https://en.wikipedia.org/wiki/Fail-fast. And perhaps that check can be less about "I started A in SkipB mode" and more about "In this state, or according to this model object, I already know fact ReportViaBOutput, I should not receive this event a second time." With all this anxiety around the flow of outputs, is there perhaps a shared injected model object that is missing? Rather than B and C posting outputs, should they be changing the state of an injected FooModel that Root monitors directly in embedded situations? |
Beta Was this translation helpful? Give feedback.
-
That doesn't seem like a terrible idea on its face, and is close to my notion of injecting a model object. |
Beta Was this translation helpful? Give feedback.
We always treat this kind of thing as a view concern, and keep our workflows/controller/presenter code out of the loop. In fact this use case is the exact reason that we introduced
ViewEnvironment, along withBackStackConfigas the very firstViewEnvironmentKey.We frequently have things like
CreatorWorkflowthat sometimes are used in the middle of a wizard-style backstack nav set, but sometimes are the first entry. In these cases, theCreatorScreen : Screenrendering is always provided with anonGoBackevent handler, which always results in aCreatorWorkflow.Outputs.GoBackoutput event. It is up to the view code …