docs(mobile/4): document the screen lifecycle events - #452
Open
sylvesterdamgaard wants to merge 1 commit into
Open
docs(mobile/4): document the screen lifecycle events#452sylvesterdamgaard wants to merge 1 commit into
sylvesterdamgaard wants to merge 1 commit into
Conversation
Covers ScreenMounted / ScreenResumed / ScreenUnmounted from NativePHP/mobile-air#248 — a new 'Observing the lifecycle from outside' section on the Lifecycle Hooks page, plus a pointer from the Events page, which until now only covered component-targeted native events. Leads with why they exist rather than what they are: the hooks are the app's to override, so a base class's mount() is the wrong home for anything cross-cutting. Also documents the two behaviours a reader would otherwise have to discover from the source — listener exceptions are logged rather than propagated, and restoring a preloaded stack after a hot reload stays quiet.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Docs for the events added in NativePHP/mobile-air#248, as requested there. That PR is approved but not yet merged — happy to hold this until it lands.
What's here
A new Observing the lifecycle from outside section on Lifecycle Hooks, covering
ScreenMounted/ScreenResumed/ScreenUnmounted: when each fires, what they carry, and how to listen.It leads with why they exist rather than what they are, because that's the part a reader can't infer. The hooks are the app's to override, so a base class's
mount()is the wrong home for anything cross-cutting — a screen defining its ownmount()silently replaces it, and the observer goes quiet on exactly the screens with the most logic in them. That failure mode is invisible until you go looking for missing data, so it seemed worth stating outright.Two behaviours are documented that a reader would otherwise have to find in the source:
Also added a short pointer from Events, which until now only covered component-targeted native events — a reader looking for "how do I observe navigation" would land there first and find nothing.
Notes
digging-deepersection.Verified the
uriclaim against the router rather than assuming it:unmountComponent()runs beforearray_pop()at all seven call sites, soScreenUnmountedreports the unmounting screen's own uri, not the one underneath it.