Native events need a lifecycle
Prerequisites: 04-turbomodule-contract, 05-expo-module-contract
Native events need a lifecycle — mechanism
Mental model verified
Native modules can emit events to JS; Expo Modules provide Events, OnStartObserving and OnStopObserving. The native producer may keep working after a screen disappears unless listener and lifecycle cleanup are explicit.
[S07] [S11]Worked example synthesis
A location feed begins when the first listener subscribes, emits compact coordinates at a useful cadence, and stops on the final unsubscribe. When the app backgrounds, decide whether collection should pause based on product requirements and platform rules.
[S07]Engineering choice synthesis
Coalesce high-frequency telemetry, send bounded payloads, and define ordering, missing-event and resubscription behavior. Use native processing when each sample need not reach JS.
[S07] [S11]Pitfall and next step synthesis
Sending every sensor sample to React state can overwhelm rendering. Measure event rate and JS frame drops; reduce frequency or aggregate natively when the UI only needs a summary.
[S07] [S12]Check yourself: What should happen when the final JS listener is removed?
Stop the native observation or release resources if no other owner needs them.