Replies: 1 comment
-
After const example = new Observable((subscriber) => {
const id = setInterval(() => {
subscriber.next();
}, 2000);
return () => {
console.log('TeardownLogic');
clearInterval(id);
};
}); The following two examples are equivalent: const subscriber1 = new Subscriber({
next: () => {
console.log('subscriber next');
subscriber1.unsubscribe();
},
error: noop,
complete: noop,
});
example$.subscribe(subscriber1); const subscriber2 = example$.subscribe({
next: () => {
console.log('subscriber next');
subscriber2.unsubscribe();
},
}); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When I see how
firstValueFrom
is defined here.Then I think the line that I selected, which for reference I'll just paste here too:
should actually be:
Right? Because why would
firstValueFrom
hold onto the subscription after the first value has passed?Maybe piping it with a
take(1)
operator isn't the cleanest solution, but do you see what I'm getting at?Beta Was this translation helpful? Give feedback.
All reactions