Props diff and streams#54
Open
mrdotb wants to merge 2 commits into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.