Episode 9 - Take 3 and complete Monday, 13 Nov.
In Episode 6 you have discovered the filtering streams category and the
❚ filter card.
❚ take, a new card from the filtering category:
▬ number on this card, such as
3, to set a maximum amount of events to emit.
❚ take returns a new stream of at most amount values:
- When the input stream emits its n-th value:
- if n < amount, the event can pass
- if n == amount, the event can pass and the stream immediately completes
What does “the stream completes” mean? As a reminder, in Episode 1 you have learned that a stream is a sequence of events over time. And in Episode 3 you have subscribed to a stream, using a listener. Let’s dive into the details now:
- A stream can emit three kinds of events:
× error: e
- After an
× error: eor a
◉ completenotification, nothing else is emitted by the stream.
- A listener can receive those three kinds of events. So, it can consume the values, handle an error and act upon completion of the subscribed stream.
Listeners can act upon stream completion, but not only them. In the next episode, you’ll see how a card can work with a completion notification.