preactjs / signals

Manage state with style in every framework
https://preactjs.com/blog/introducing-signals/
MIT License
3.79k stars 93 forks source link

Typo in invalidated batch example in README #89

Closed kim3er closed 2 years ago

kim3er commented 2 years ago

In the following example:

import { signal, computed, effect, batch } from "@preact/signals-core";

const counter = signal(0);
const double = computed(() => counter.value * 2);
const tripple = computed(() => counter.value * 3);

effect(() => console.log(double.value, tripple.value));

batch(() => {
    counter.value = 1;
    // Logs: 2, despite being inside batch, but `tripple`
    // will only update once the callback is complete
    console.log(counter.double);
});
// Now we reached the end of the batch and call the effect

I think counter.double should read double.value.

marvinhagemeister commented 2 years ago

Fixed by #90