Considering the following setup
of('x')
.pipe(
startWith('y'),
debounceTime(1000))
.subscribe(console.log);
It prints without any delay the valye 'x'
Doing the same thing as follows
const clicks = fromEvent(document, 'click');
clicks
.pipe(
map(() => 'x'),
startWith('y'),
debounceTime(1000)
)
.subscribe(console.log);
I do get that delay for the inital value y and also later for each click. So the question is, why do I not get any delay when using of?
of()completes immediately after emitting its only value. In this case,debounceTime()does not wait, but also emits right away. From the docs:fromEvent()does not complete, so the behavior is as you would expect.