id | mainCompare | lesson | seeAlso | seeAlsoLink | title | compare | learnBackAbout | learnAbout | video | layout | class | preview_image | preview_image_alt | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
takeWhile |
take |
17 |
skipWhile vs takeWhile |
skipWhile |
take vs takeWhile in RxJS |
|
take |
skipWhile |
250094761 |
default |
post |
takeWhile/content_preview.jpg |
In the animation above, can you spot the difference between the outputs? Can you explain why?
Answer: the ◉ complete
notification happens at a different moment:
- On the one hand,
❚ take
returns a stream that emits at most amount values and can complete as soon as this amount is reached. - On the other hand,
❚ takeWhile
has to wait for the predicate to return✘ false
in order to complete.