take
accepts
1 input stream,
an amount
amount, the value is emittedamount, the value is emitted and the stream immediately completesreturns
a new stream of at most amount values
takeLast
accepts
1 input stream,
an amount
amount values emitted by the input stream (they are emitted as separate event values)returns
a new stream of at most amount values
Learn more about stream completion.
Use a ▬ number on these cards, such as 3, to set a maximum amount of events to emit. ❚ take and ❚ takeLast share identical behavior:
The stream returned by ❚ take emits the values at the same time as their counterpart on the input stream. This is not the case for ❚ takeLast. Remember: a stream is a sequence of events over time. And we can’t see the future! takeLast must wait for the ◉ complete notification. Only then, we know what are the last values.
See also
Freelance Developer Advocate. Motion graphics with code. JavaScript and Elm. cedricsoulas.com
Receive my latest news, product updates and programming visualizations. You can unsubscribe at any time.