DEV Community

Discussion on: Building a Reactive Library from Scratch

Collapse
 
hugeletters profile image
Evgenii Perminov

Late reply but a simple example

const a = createSignal(1);
const b = createComputed(() => a.value * 3);
createEffect(() => logEffect(`A is ${a.value} and B is ${b.value}`));
a.value = 2;

Enter fullscreen mode Exit fullscreen mode

This effect runs three times, not two - because update to a triggers update to b which triggers effect but also update to a itself triggers effect too