LiveReactNative (live_react_native v0.0.3)

View Source

Pure state management for Phoenix LiveView mobile apps.

Sends LiveView assigns as JSON over WebSocket to React Native apps. No HTML rendering or component orchestration - just clean state management.

Summary

Functions

Generate structural and data fingerprints for assigns.

Batch multiple assign changes for efficient transmission.

Extract user assigns from LiveView assigns, filtering out Phoenix internals.

Generate granular diff between old and new assigns, tracking specific changed paths.

Generate minimal diff containing only changed values and operations.

Returns true when the socket is served over the mobile channel transport.

Extract and serialize LiveView assigns for mobile transmission.

Functions

assigns_fingerprint(assigns)

Generate structural and data fingerprints for assigns.

Structure fingerprint changes when assigns shape changes (new keys, different types). Data fingerprint changes when values change but structure stays the same.

batch_assigns_changes(changes, opts \\ [])

Batch multiple assign changes for efficient transmission.

Combines rapid changes into single update, with optional prioritization for UI-critical updates vs background data changes.

extract_user_assigns(assigns)

Extract user assigns from LiveView assigns, filtering out Phoenix internals.

granular_assigns_diff(old_assigns, new_assigns)

Generate granular diff between old and new assigns, tracking specific changed paths.

Returns detailed information about what exactly changed, enabling surgical React Native updates instead of full re-renders.

minimal_assigns_diff(old_assigns, new_assigns)

Generate minimal diff containing only changed values and operations.

Instead of sending full assigns, sends only the deltas needed to update the React Native app, dramatically reducing network payload.

mobile?(socket)

Returns true when the socket is served over the mobile channel transport.

Lets a shared LiveView branch on transport (e.g. emit RN commands on mobile, redirect on web). Reads the :transport marker the mobile channel places in connect_info; web sockets never carry it.

serialize_assigns(assigns)

Extract and serialize LiveView assigns for mobile transmission.

Takes LiveView assigns, filters out Phoenix internals, and returns clean data ready for JSON serialization over WebSocket to React Native.