Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fine-grained reactivity and nested actor support #508

Open
NullVoxPopuli opened this issue Oct 22, 2024 · 0 comments
Open

Fix fine-grained reactivity and nested actor support #508

NullVoxPopuli opened this issue Oct 22, 2024 · 0 comments

Comments

@NullVoxPopuli
Copy link
Owner

NullVoxPopuli commented Oct 22, 2024

Will need to extend Actor: https://github.com/statelyai/xstate/blob/b730b298994aa00e0a76783d747c8063853d389e/packages/core/src/createActor.ts#L64

and not use createActor just instantiates the default Actor.

However, the whole snapshot is replaced here: https://github.com/statelyai/xstate/blob/b730b298994aa00e0a76783d747c8063853d389e/packages/core/src/createActor.ts#L241

so that means we need to intercept that and deeply diff the values before assigning.
(VDOM, but it JS 🙃)

getSnapshot() just returns the _snapshot (which we need to intercept): https://github.com/statelyai/xstate/blob/b730b298994aa00e0a76783d747c8063853d389e/packages/core/src/createActor.ts#L747

So, if we override the update method, and then have our own snapshot property, and yield that out to consumers, then we get very targeted DOM updates without re-rendering.

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

No branches or pull requests

1 participant