appyx icon indicating copy to clipboard operation
appyx copied to clipboard

Node Lifecycle

Open ganfra opened this issue 1 year ago • 3 comments

Hello there, more a question than an issue.

I've the following configuration : a ParentNode with 1 child Node. I'm listening to the Lifecycle of each Node to make some init/cleanup

init {
       lifecycle.subscribe(
           onCreate = {
               
           },
           onDestroy = {
              
           }
       )
   }

When using navigateUp on the child Node, the ParentNode enters onDestroy before his child Node. I'd have expected the opposite actually. Is it expected?

Thanks!

ganfra avatar Jun 29 '23 16:06 ganfra

@zsoltk any thoughts on this? I'd like to wait for all my children to be destroyed before doing some clean-up.

ganfra avatar Jul 24 '23 19:07 ganfra

@KovalevAndrey just bumping on this as it's still creating issues for us. Is there any reason why a child onDestroy is called after his parent onDestroy? Any other way we could synchronise on this?

ganfra avatar Sep 25 '23 18:09 ganfra

@ganfra sorry for the late response. Atm there's no mechanism implemented to guarantee the lifecycle order. Children are moved toDESTROYED state when the parent's lifecycle scope is cancelled. To support that we'd need to re-think the approach. What's the problem you're trying to solve that you care about the order? Perhaps, there's another way to solve this?

KovalevAndrey avatar Sep 26 '23 07:09 KovalevAndrey