benkuly
12/04/2024, 12:37 PMThe lifecycle of a child ComponentContext must never be destroyed manually.
Arkadii Ivanov
12/04/2024, 6:36 PMComponentContext
created via childContext
is attached to the parent ComponentContext
, i.e. it saves/restores the state, keeps its retained InstanceKeeper.Instance
, handles back button presses, etc. If you need to dynamically switch components, then most likely you need navigation.Arkadii Ivanov
12/04/2024, 6:37 PMLifecycleRegistry
manually.benkuly
12/05/2024, 6:32 AMArkadii Ivanov
12/05/2024, 9:23 AMbenkuly
12/05/2024, 9:30 AMDefaultComponentContext(MergedLifecycle(this.lifecycle, lifecycle))
but this is only a workaround. I still don't see, why it is not allowed to destroy the lifecycle of a child. Is there any technichal limitation?Arkadii Ivanov
12/05/2024, 9:43 AMbenkuly
12/05/2024, 9:48 AMDefaultComponentContext(MergedLifecycle(this.lifecycle, lifecycle))
okay instead of copying many internal functions of decompose?Arkadii Ivanov
12/05/2024, 9:54 AMbenkuly
12/05/2024, 12:49 PMdestroy
creates a memory leak, but how the child is (or is not) created, because it is not permanent.
With that in mind it seems to be okay to call DefaultComponentContext(MergedLifecycle(this.lifecycle, lifecycle))
for each element in the list as it is either manually destoyed or removed by the garbage collector, because no one holds a reference to it.Arkadii Ivanov
12/05/2024, 4:52 PMWith that in mind it seems to be okay to callYes, though only thefor each element in the list as it is either manually destoyed or removed by the garbage collector, because no one holds a reference to it.DefaultComponentContext(MergedLifecycle(this.lifecycle, lifecycle))
Lifecycle
from the created DefaultComponentContext
will be functional. The reset won't work, which may also affect nested navigation if needed.Arkadii Ivanov
12/05/2024, 4:53 PMLifecycle
instead of the ComponentContext
.benkuly
12/06/2024, 8:30 AMArkadii Ivanov
12/06/2024, 9:02 AM