In Lesson 1 you created a stream of toggle events. When an action is performed on the toggle (on→off or off→on), a toggle event is emitted.

You can find dozens of properties inside each of this toggle event. In particular, there is a property about the status of the toggle after the action. This is what we are looking for!

▬ isChecked is a function that accepts events from checkable elements (such as checkboxes, radio buttons, options of a menu, toggles, etc). It returns ✔ true if the element is checked, ✘ false otherwise.

Here is how it works with ❚ map:

Use a project function on this card, such as ▬ isChecked. Then, this is how ❚ map operates:

  • It waits for events from an input stream
  • It projects each event of this input stream with a project function
  • As a result, it returns a new stream of projected events

A card never modifies the input stream. Instead, it returns a new stream. This principle is called immutability.

💌 Learn Reactive Programming and stay tuned

Occasional updates, plus: