So far you learned 2 essential Reactive Programming principles: streams and immutability. Today we explore a third principle: reactivity. You’ll need:
▬ setWifilistener piece
▬ setWifilistener piece. It turns the wifi on or off.
You also need all the cards and pieces you previously received. Let’s put them all together like this:
Yes! You can put cards one after another, in a chain. Each card in this chain operates on the stream generated by the previous card:
❚ fromEventreacts to the
▬ toggle. It creates a sequence of toggle events over time, in reaction to each toggle status change (read Episode 1).
❚ mapprojects each toggle events to
✘ false(read Episode 2).
▬ setWifias a listener of the stream. This listener accepts boolean values (
✘ false) and turns the wifi on or off accordingly.
In Reactive Programming we react to piece and stream updates. This is the reactivity principle. And today, by assembling several cards together, you built your first reactive machine!
You now have the basic knowledge of Reactive Programming. Over the next lessons, you’ll receive new cards that transform streams.
Receive my latest news, product updates and programming visualizations. You can unsubscribe at any time.