halfnelson / svelte-native

Svelte controlling native components via Nativescript
MIT License
1.8k stars 78 forks source link

onDestroy not called when navigating #314

Open daveychu opened 2 years ago

daveychu commented 2 years ago

With Svelte we can do some cleanup when a component is destroyed by either returning a function in onMount or using onDestroy. These are both ignored when navigating back via actionBar or using navigate.

Reproduction: https://github.com/daveychu/svelte-native-on-destroy-bug

CatchABus commented 1 year ago

Page components are usually cached for backwards navigation, and that might be why you face this problem. Upon navigating back using back button or goBack method, component will trigger onDestroy callback.