Part 4 · Fundamentals

Kotlin and Swift meet the OS

Prerequisites: Start here / basic technical literacy

Platform resource ownership

The Promise is a JS interface; native lifecycle and OS callbacks decide when it settles. Nodes: JS Promise, Native module, Android, iOS, OS callback.
The Promise is a JS interface; native lifecycle and OS callbacks decide when it settles. [S12] [S16] [S17]

Mental model verified

Android native code interacts with Activity, View, SDK callbacks and the main Looper. iOS code interacts with UIKit, application/scene lifecycle and the main actor or main queue. A module mediates these APIs for JS; the native platform still owns its resources and permissions.

[S12] [S15] [S17] [S18]

Worked flow synthesis

A camera picker starts platform UI, returns a URI or asset handle, and is cancelled or completed by an OS callback. The module must translate that outcome into the JS contract and clean up if its owning screen disappears.

[S12] [S15] [S17]

Engineering decision synthesis

Make thread, ownership and lifecycle explicit for every native resource. Design cancellation, error mapping and permission denial before exposing a JS function.

[S12] [S16] [S18]

Failure mode and improvement synthesis

Holding an old Activity or view reference after recreation can leak or crash. Tie work to a valid owner and test background/foreground, dismissal and recreation on devices.

[S12] [S16]
Keep this: Native module code runs inside real Android/iOS app lifecycles; a JS Promise cannot erase their rules.
Check yourself: Which thread should create or mutate host UI views?

The platform UI/main thread; background work belongs on an appropriate worker or async execution context.

Sources & further reading

  1. [S12] Module API Reference

    Expo · official documentation or maintainer source · accessed 2026-10-09 · current documentation as accessed; examples conceptual

    Supports: Function, AsyncFunction, queues, views, events and lifecycle.

    Inspect the implementation boundary described by this source.

  2. [S15] Kotlin coroutines on Android

    Android Developers · official documentation or maintainer source · accessed 2026-10-09 · current documentation as accessed; examples conceptual

    Supports: Async work and structured cancellation for Android.

    Inspect the implementation boundary described by this source.

  3. [S16] Use Kotlin coroutines with lifecycle-aware components

    Android Developers · official documentation or maintainer source · accessed 2026-10-09 · current documentation as accessed; examples conceptual

    Supports: Activity lifecycle scopes and cancellation.

    Inspect the implementation boundary described by this source.

  4. [S17] UIKit

    Apple Developer · official documentation or maintainer source · accessed 2026-10-09 · current documentation as accessed; examples conceptual

    Supports: UIKit objects are normally used from the main thread.

    Inspect the implementation boundary described by this source.

  5. [S18] MainActor

    Apple Developer · official documentation or maintainer source · accessed 2026-10-09 · current documentation as accessed; examples conceptual

    Supports: Swift main actor execution contract.

    Inspect the implementation boundary described by this source.