Skip to content

Props diff and streams#54

Open
mrdotb wants to merge 2 commits into
mainfrom
props-diff-and-streams
Open

Props diff and streams#54
mrdotb wants to merge 2 commits into
mainfrom
props-diff-and-streams

Conversation

@mrdotb

@mrdotb mrdotb commented Jul 17, 2026

Copy link
Copy Markdown
Owner

No description provided.

mrdotb added 2 commits July 13, 2026 11:37
Ports live_vue's incremental props-diffing and Phoenix.LiveView stream
support into live_react. Structs now flow through a new LiveReact.Encoder
protocol (replacing raw Jason.Encoder) so they can be safely diffed;
Jsonpatch computes minimal prop diffs and a hand-rolled algorithm reads
Phoenix.LiveView.LiveStream inserts/deletes directly, delivering both as
compact patch operations over data-props-diff/data-streams-diff instead of
re-sending full props on every update. The client applies patches
copy-on-write so React.memo'd components correctly skip re-rendering
untouched data and re-render changed data.

- LiveReact.Patch: compact wire-format codec shared by both diff channels
- LiveReact.Encoder: struct -> map protocol (AsyncResult, UploadConfig,
  UploadEntry, Phoenix.HTML.Form)
- react/1: LiveStream classification, props_diff via Jsonpatch.diff/3,
  streams_diff computed from stream inserts/deletes/resets, diff={false}
  per-component opt-out, enable_props_diff config (default true)
- Client: compactPatch.js/jsonPatch.js (copy-on-write patch application),
  hooks.js persistent props/streams state across mounted/updated/
  reconnected/destroyed
- New Vitest+jsdom test infrastructure for the client library
- Example stream-demo LiveView + React component (add/update/delete) for
  manual verification

BREAKING CHANGE: data-props is now encoded via LiveReact.Encoder instead
of Jason.Encoder. Struct props must now `@derive LiveReact.Encoder` (or
implement it explicitly); plain maps are unaffected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant