Skip to content

Fix fine-grained reactivity and nested actor support #508

@NullVoxPopuli

Description

@NullVoxPopuli

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions