| id | takeWhile | ||
|---|---|---|---|
| mainCompare | take | ||
| lesson | 17 | ||
| seeAlso | skipWhile vs takeWhile | ||
| seeAlsoLink | skipWhile | ||
| title | take vs takeWhile in RxJS | ||
| compare |
|
||
| learnBackAbout | take | ||
| learnAbout | skipWhile | ||
| video | 250094761 | ||
| layout | default | ||
| class | post | ||
| preview_image | takeWhile/content_preview.jpg | ||
| preview_image_alt |
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,
❚ takereturns a stream that emits at most amount values and can complete as soon as this amount is reached. - On the other hand,
❚ takeWhilehas to wait for the predicate to return✘ falsein order to complete.
{:.w300}