As @Jopie64 describes in #7, in an expression with a condition there might be a case when an Observable becomes unused:
const ms = timer(0, 1);
const s = timer(0, 1000);
run(() => $(s) % 2 : $(ms) : 'even');
Steps of calculation:
s=0 that would result to "even"
s=1 that would lead to subscription to ms and a thousand of ms values (or ~ thousand)
s=2 means that expression emits "even" and ms stream is not needed for the next second
s=3 means ms stream is again used and we'll emit a thousand of ms values
Current behavior:
Due to ms being tracked, the expression would be still needlessly recalculated a thousand times. Even though at step # 3 we learned that ms is not used when s=2.
Expected behavior:
I think, when ms is detected unused on step # 3, we should mark it as "untracked" until it is again used. So $ turns under the hood into _ until it's used again.
As @Jopie64 describes in #7, in an expression with a condition there might be a case when an Observable becomes unused:
Steps of calculation:
s=0
that would result to"even"
s=1
that would lead to subscription toms
and a thousand ofms
values (or ~ thousand)s=2
means that expression emits"even"
andms
stream is not needed for the next seconds=3
meansms
stream is again used and we'll emit a thousand ofms
valuesCurrent behavior: Due to
ms
being tracked, the expression would be still needlessly recalculated a thousand times. Even though at step # 3 we learned thatms
is not used whens=2
.Expected behavior: I think, when
ms
is detected unused on step # 3, we should mark it as "untracked" until it is again used. So$
turns under the hood into_
until it's used again.