Hey there, consider following scenario: I have a n...
# decompose
m
Hey there, consider following scenario: I have a navigation component that hosts one ChildSlot and one ChildStack. Also, each screen in my app is represented by a Component. • The stack displays application screen components in a classic push-pop manner. • The slot, on the other hand, displays some of my application’s screens as sheet-like overlay over rest of my screens in the stack. When I activate something in the slot, I would like the rest of my screens in the stack to go from RESUMED to STARTED lifecycle state and when I dismiss the slot, rest of the screens in the stack should go back from STARTED to RESUMED (onResume is called on their lifecycles). Do I need to implement some custom navigation model for that? 🤔 (My ultimate goal is to implement screen tracking analytics in KMP — I want to track which screens users visit as they navigate around my app, and the easiest solution looks like tracking such event in component lifecycle’s
onResume
callback. I need to track these events when the screen is also displayed again after closing the sheet, which is why I need that
onResume
to fire again when user closes the sheet.)
a
There could be multiple options. I think the following is one of the easiest.
m
Hmm, I see… interesting approach. And since the provided Lifecycle is merged with the parent one, it will get destroyed automatically. Thanks!
a
Yep! Just make sure you never destroy the lifecycle. The stack will be destroyed automatically once the hosting component is destroyed.
I would just try, and if it's not working then comment in the issue. 😀
m
I gave it a quick try and it looks like this approach will be the way 🙌
K 1