@molecule/app-lifecycle-react-native
v1.0.1
Published
React Native lifecycle provider for molecule.dev (AppState)
Maintainers
Readme
@molecule/app-lifecycle-react-native
Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit
src/index.tsJSDoc, not this file.
React Native lifecycle provider for molecule.dev.
Uses react-native AppState + Linking to implement the
LifecycleProvider interface from @molecule/app-lifecycle: app-state
changes, deep-link URL opens, and memory warnings.
Quick Start
import { setProvider } from '@molecule/app-lifecycle'
import { provider } from '@molecule/app-lifecycle-react-native'
setProvider(provider) // once, at app startup — before any lifecycle callType
provider
Installation
npm install @molecule/app-lifecycle-react-native @molecule/app-i18n @molecule/app-lifecycle @molecule/app-logger react-nativeAPI
Interfaces
ReactNativeLifecycleConfig
Configuration for the React Native lifecycle provider.
interface ReactNativeLifecycleConfig {
/**
* Whether to track deep link URL open events.
* @default true
*/
trackUrlOpen?: boolean
/**
* Whether to track memory warnings.
* @default true
*/
trackMemoryWarnings?: boolean
/**
* URL for active connectivity checks.
* Should return a fast, lightweight response (e.g. HTTP 204).
* @default 'https://clients3.google.com/generate_204'
*/
connectivityCheckUrl?: string
/**
* Timeout in milliseconds for connectivity checks.
* @default 5000
*/
connectivityCheckTimeout?: number
}Functions
createReactNativeLifecycleProvider(config)
Creates a React Native lifecycle provider backed by react-native AppState.
function createReactNativeLifecycleProvider(config?: ReactNativeLifecycleConfig): LifecycleProviderconfig— Optional provider configuration.
Returns: A LifecycleProvider implementation for React Native.
Constants
provider
Default React Native lifecycle provider.
const provider: LifecycleProviderCore Interface
Implements @molecule/app-lifecycle interface.
Bond Wiring
Setup function to register this provider with the core interface:
import { setProvider } from '@molecule/app-lifecycle'
import { provider } from '@molecule/app-lifecycle-react-native'
export function setupNativeLifecycleReactNative(): void {
setProvider(provider)
}Injection Notes
Requirements
Peer dependencies:
@molecule/app-i18n^1.0.1@molecule/app-lifecycle^1.0.1@molecule/app-logger^1.0.1react-native>=0.72.0
Runtime Dependencies
@molecule/app-i18n@molecule/app-lifecycle@molecule/app-loggerreact-nativeWire
setProvider()before any lifecycle call. The core lazily bonds a browser-API WEB fallback on first use — subscribe early with no provider bonded and you're on the web provider, not this one.Only app-state, URL-open, and memory-warning events fire.
onNetworkChange,onBatteryChange, andonTerminateaccept listeners but are NEVER invoked by this bond, andgetBatteryState()always resolvesnull— use@molecule/app-network-react-nativefor reactive connectivity and a dedicated battery integration (e.g. expo-battery) instead.getNetworkState()performs an active HTTP HEAD probe on every call — by default tohttps://clients3.google.com/generate_204. PointconnectivityCheckUrlat your own endpoint if third-party egress is a concern;connectionTypeis always'unknown'here.getLaunchInfo().coldStartis alwaystrue;destroy()detaches the native subscriptions.
