Part 7 · Best practices

Native events need a lifecycle

Prerequisites: 04-turbomodule-contract, 05-expo-module-contract

Native events need a lifecycle — mechanism

Event lifecycle and data flow. Aggregation and event ordering must be designed for the particular producer. Nodes: Native producer, Subscription, Event payload, JS listener, Cleanup.
Event lifecycle and data flow. Aggregation and event ordering must be designed for the particular producer. [S07] [S11]

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]
Keep this: Events are a subscription with cleanup and throughput policy, not an unlimited stream of JS callbacks.
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.

Sources & further reading

  1. [S07] Expo Modules API: Reference

    Expo · official documentation · accessed 2026-10-08 · current documentation as accessed

    Supports: JSI abstraction; Function, AsyncFunction, queues, views, events and lifecycle.

    Read the diagrams and API boundaries for jsi abstraction; function, asyncfunction, queues, views, events and lifecycle.

  2. [S11] Emitting Events in Native Modules

    React Native · official documentation · accessed 2026-10-08 · current documentation as accessed

    Supports: Native-to-JS events in TurboModules.

    Read the diagrams and API boundaries for native-to-js events in turbomodules.

  3. [S12] Performance Overview

    React Native · official documentation · accessed 2026-10-08 · current documentation as accessed

    Supports: JS and UI frame rates and practical performance diagnosis.

    Read the diagrams and API boundaries for js and ui frame rates and practical performance diagnosis.