Skip to content

Reactivity: only subscribe components during rendering #1574

Open
@sdegueldre

Description

@sdegueldre

It's pretty common to have event handlers that mutate the state, and in doing so, need to read the current state.

Currently, this subscribes the component and immediately re-renders it, even though in practice the DOM of the component does not depend on the value that was written

Playground example

One workaround for this is to wrap the reactive object that we're about to modify in a fresh reactive with no callback, but this is not ergonomic and unintuitive

Playground example

Ideally, reactives bound to components should only subscribe to keys that are read during rendering or a rendering-adjacent activity (willRender/rendered/willPatch/patched)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions