Skip to content

Commit

Permalink
Add Episode 10 (last)
Browse files Browse the repository at this point in the history
Fix typo in episode 9
  • Loading branch information
cedricss committed Nov 20, 2017
1 parent fc167d0 commit b3533a8
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 1 deletion.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Expand Up @@ -8,12 +8,24 @@ preview_image: changelog_preview.jpg

[reactive.how](http://reactive.how), learn reactive programming.

## `16.0` Nov 20, 2017

### 🃏
- Add [Episode 10 - Last value?](/last)

## `15.0` Nov 13, 2017

### 🃏
- Add [Episode 9 - Take 3 and complete](/take)

## `14.0` Nov 6, 2017

### 🃏
- Add [Episode 8 - zip vs combineLatest](/zip)

## `13.0` Oct 30, 2017

### 🃏
- Add [Episode 7 - combineLatest vs merge](/combineLatest)

## `12.1` Oct 24, 2017
Expand Down
7 changes: 7 additions & 0 deletions _data/course.yml
Expand Up @@ -60,3 +60,10 @@ lessons:
- 242296640
date: Monday, 13 Nov.

- name: Last value?
card: last
videos:
-
- 242933193
date: Monday, 20 Nov.

34 changes: 34 additions & 0 deletions last.md
@@ -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
2 changes: 1 addition & 1 deletion take.md
Expand Up @@ -14,7 +14,7 @@ Here is `❚ take`, a new card from the filtering category:

{% include card_player.html video=242296640 episode=true %}

Use a `▬ 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_ events:
Use a `▬ 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
Expand Down

0 comments on commit b3533a8

Please sign in to comment.