Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix typo in episode 9
- Loading branch information
Showing
4 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
id: last | ||
lesson: 10 | ||
title: Learn Reactive Programming - Episode 10 (Last) | ||
layout: default | ||
class: post | ||
preview_image: last/content_preview.jpg | ||
preview_image_alt: The "last" operator | ||
--- | ||
|
||
Today, we explore a card named `❚ last`. It returns the last value of a stream. As soon as the last value is emitted, it returns it? Naaah! How could one be certain that no value comes after? Reactive programming can't see the future. | ||
|
||
We have to wait for a `◉ complete` notification (read [Episode 9 - Take 3 and complete](/take) to learn more about it). Only when the stream has completed, we know this value was the last one – **and this completion may never happen**! | ||
|
||
Last Monday, we used the card `❚ take` (watch it again below). The stream it outputs has a `◉ complete` notification overlapped by the `3` value, as it completes immediately. I would like to emphasize that this notification is **not** intended to deliver the last value of the stream. It is a separate event, without a value (though it can happen immediately after an event value). | ||
|
||
To illustrate all those principles, let's see how `❚ last` and `❚ take` work with an input stream that completes **few seconds** after the last emitted value: | ||
|
||
{% include card_player.html video=242933193 episode=true %} | ||
|
||
This is how `❚ last` operates with one input stream: | ||
|
||
- **When the input stream completes**, the output stream: | ||
- emits the last value emitted by the input stream | ||
- and immediately completes | ||
|
||
So, this card returns a new stream of **at most** one value. | ||
|
||
## Summary | ||
|
||
- A stream can complete emitting a notification (read [Episode 9](/take)) | ||
- The `◉ complete` notification is a special event with no value | ||
- A listener can subscribe to a stream and act upon its completion | ||
- Also, the behavior of some cards like `❚ last` is based on this notification |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters