Notice when leaving a component




anyone have an elegant solution to know when a component is exited? in order to do some conditional cleanup. Specially when routing logic matches a global intent in another component

I think event middleware could do it but coding is required for that case

Also, I would like that logic to go inside the “leaving” component. So I can still access component data etc.

Something like “ON_LEAVE()”.

Am I missing something? Does it seems reasonable for you?


Thank you, this sounds like an interesting approach.

With “leaving” you mean that either a new component is added to the state stack (the old component remains there) or the component is removed from the state stack (e.g. by using $resolve)?


When a Global handler is matched I think the state is cleared (no resolve), so I have to check History to do my logic. I think this is related to a PR that solved issues with PrioritizeOverUnhandled.

Im mixing up concepts but maybe it can be accomplished at component or handler level, you know, if a component coudn’t be exited without explicit redirect or resolve… UNHANDLED accomplish this but is weird because you have to do your logic and then redirect to the specific Component manually, because Jovo already routed that request. For me its reasonable to have that ON_LEAVE handler that does some logic and then optionally routes the intent again (modifiying the request or not). Note that the “again” part is important. The possibility of “going back” in the pipeline it’s also interesting.

I think more helper methods to acess or search the state (or “state history”) would be great too.