-
Notifications
You must be signed in to change notification settings - Fork 36
Description
When trying the following code
const obs = observable(1);
const observer = () => { console.log("inside: " + obs()); return obs() };
const comp = computed(observer);
const unsub = subscribe(() => console.log(comp()));
obs(2);
unsub();
obs(3);
unsubscribe(observer);
obs(4);we get the output
inside: 1
1
inside: 2
2
inside: 3while I would kind of expect the logs from inside the computed to stop after the unsub(). But this is only the case when I call unsubscribe on the function that went into computed (which also puzzled me a bit).
Is it desirable that computeds still fire internally even when their output (data) is not subscribed to?
I think my use case with the pipe functionality that I am building would benefit greatly from automatic internal unsubscribe from a computeds observable inputs, because that would propagate up the chain, eventually allowing me to detect a whole chain has become unobserved at the beginning of the chain, which then allows me to stop the Websocket connection that produces the data for the chain.