Skip to content

Unable to reset a value within the same tick #111

Description

@smhg

This is the original (potential) issue I wanted to report:

When, within the same 'tick', you change a value and then change it again, but back to the original value, the updated cortex does not register that last change.

let cortex = new Cortex({a: 1}, cortex => {
  // the new cortex here will contain {a: 2} after the script finishes
});

cortex.a.set(2);
cortex.a.set(1);

To clarify: this only happens when your last call to set (within the same tick) contains the original value (the value your cortex had at the start of the tick). Cortex compares them and sees no change, so decides no update is necessary if I understood right.

PR with failing test coming up.

Feel free to ignore if this is by design. It just felt awkward when I bumped into this issue.
I now fixed it by calling the second set inside a setTimeout.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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