Skip to content

Shallow compare in reactive bindings #2959

@ghost

Description

Here's an example:
https://svelte.dev/repl/908698aa30ad46ba92569e5060e6f73b?version=3.4.4

If you press either of the buttons, the reactive block will be re-evaluated, even though it only depends on the subset of state object. In react, afair, they use shallow compare on component side to determine if relevant pieces of state changed, and this stops redux from triggering render on every state change.

I understand that svelte maybe was not intended to be used with reducers, but I'm currently working on a toy project which gives me an impression that svelte can actually work with reducers very well and even be more convenient than react by using reactive bindings to pieces of state.

My current workaround here is to compare manually like this:
https://svelte.dev/repl/c9152261372e4d109352e5ce7da2271d?version=3.4.4

Is there anything to automate these compares or maybe plans to support this in future?
This feature seems not very complicated, but will make svelte more appealing to redux fans.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions