-
Hi. I wonder if it's possible to gain control over a component's lifecycle by accessing it's |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Components can't control their lifecycle - that's the parent's responsibility. On the parent's side, that depends on how child components are created. If you are using If you are using val stackLifecycle = LifecycleRegistry()
val childStack = childContext(key = "stack", lifecycle = stackLifecycle).childStack(...)
stackLifecycle.resume()
stackLifecycle.stop()
// Never destroy the lifecycle manually! |
Beta Was this translation helpful? Give feedback.
-
Oh that's right, the parent should be responsible for it, which is the very definition of connections between parent and children in the BLoC tree. Your response answers the question in full details. Thanks! |
Beta Was this translation helpful? Give feedback.
Components can't control their lifecycle - that's the parent's responsibility. On the parent's side, that depends on how child components are created.
If you are using
childContext
, then you can passLifecycleRegistry
there for manual control. Please also mind the pending API change - #202.If you are using
childStack
, then there is no direct API of controlling the lifecycle, and it's advised not to interfere with it. But if you really need to, you can try the following: