ns-page-navigation-lifecycle
Installation
SKILL.md
Page navigation lifecycle and the backstack
For one forward navigation followed by back, a page fires exactly this sequence:
navigatingTo → loaded → navigatedTo ... navigatingFrom → unloaded → navigatedFrom
What is true at each step:
navigatingTo— earliest hook;args.context(theNavigationEntry.context) is available. SetbindingContexthere.loaded— the view tree exists and native views are attached, butFrame.topmost().currentPageis NOT this page yet. Don't read "the current page" here expecting yourself.navigatedTo— navigation committed;currentPageis now this page. Start animations, timers, subscriptions here.navigatingFrom/unloaded/navigatedFrom— noteunloadedfires BEFOREnavigatedFrom. Teardown that needs the native view must happen byunloaded;navigatedFromis last and runs on an already-unloaded page.- After a back-pop the page is fully torn down:
parent,frameand the native context are null,isLoadedis false. Never cache a popped Page for reuse. page.navigationContextis cleared on back navigation — read what you need from it before leaving, or copy it onto your view model.
import { EventData, NavigatedData, Page } from '@nativescript/core';