Skip to content

Solid v2.0.0-beta.10 batched parent & derived signals manual update is neglected for derived signals #2692

@maciek50322

Description

@maciek50322

Describe the bug

When updating parent signal and derived signal in one "batch", the derived signal update has no effect independent of update order.

const [original, setOriginal] = createSignal(0);
const [derived, setDerived] = createSignal(original);

function onClick() {
  setOriginal(1); // sets both derived signals to 1
  setDerived(2); // doesn't do anything
}

This happens only for first call of onClick, because on second call original signal already has new value and so doesn't update - this allows derived signal to update.

This can be mitigated right now with flush

function onClick() {
  setOriginal(1); // sets both derived signals to 1
  flush();
  setDerived(2); // sets derived signal to 2
}

but flush can't be used in e.g. onSettled
and flushing it at that point makes more updates

Your Example Website or App

https://s.olid.uk/id/iMjvvK2zQbi-c6TJvUWsDA

Steps to Reproduce the Bug or Issue

  1. Go to link
  2. Click the button
  3. See that both signals have value of 1 instead of 1 and 2
  4. Click the button again
  5. See that signals have now values of 1 and 2

Expected behavior

Updates to signals should be applied in call order.

Screenshots or Videos

No response

Platform

  • OS: Windows 10
  • Browser: Chrome
  • Version: Solid v2.0.0-beta.10

Additional context

No response

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