angular icon indicating copy to clipboard operation
angular copied to clipboard

refactor: fix input signal not allowing new values

Open devversion opened this issue 2 years ago • 0 comments

If InputSignal is computed once, it will never re-compute unless the actual user computation changes. This may not be the case when:

  • the input signal is only ever changing using bindToValue. e.g. when Zone components bind to the signal input.

  • the input signal is initialized with an initial value, and read before the computation is set. This should never happen in practice because we are guarding by initialized() but it highlights the issue that switchedComputation needs a way to be notified of change.

Even if we set stale=true, it doesn't guarantee that switchedComputation is re-evaluated because the reactive graph will actually poll all consumed producers and realize that nothing changes because e.g. we always deal with static values.

We fix this for now (needs more optimization/performance insights) by adding an producer that we can use to notify the computation.

devversion avatar Jun 23 '23 15:06 devversion