Currently, when calling a signal, if the current activeSub is not flagged as Mutable or Watching, the signal will recursively search for a parent sub with either flag set. Once it finds one, it will link to that sub.
However, computed signals always link to the current activeSub, regardless of whether it is Mutable or Watching:
const a = signal(0);
const b = computed(() => 0);
let triggers = 0;
effect(() => {
triggers += 1;
effectScope(() => {
effectScope(() => {
a();
b();
});
});
});
console.log(triggers); // 1
a(a() + 1);
console.log(triggers); // 2 - signal A linked to effect
trigger(b);
console.log(triggers); // 2 - computed B linked to effectScope
This seems like a bug, since a signal and a computed called in the same scope under an effect will be linked to different nodes.