Chapter 13. Why Reactivity?
Introduction
The initial impression of Shiny is often that itâs âmagic.â Magic is great when you get started because you can make simple apps very, very quickly. But magic in software usually leads to disillusionment: without a solid mental model, itâs extremely difficult to predict how the software will act when you venture beyond the borders of its demos and examples. And when things donât go the way you expect, debugging is almost impossible.
Fortunately, Shiny is âgoodâ magic. As Tom Dale said of his Ember.js JavaScript framework: âWe do a lot of magic, but itâs good magic, which means it decomposes into sane primitives.â1 This is the quality that the Shiny team aspires to for Shiny, especially when it comes to reactive programming. When you peel back the layers of reactive programming, you wonât find a pile of heuristics, special cases, and hacks; instead youâll find a clever but ultimately fairly straightforward mechanism. Once youâve formed an accurate mental model of reactivity, youâll see that thereâs nothing up Shinyâs sleeves: the magic comes from simple concepts combined in consistent ways.
In this chapter, weâll motivate reactive programming by trying to do without it and then give a brief history of reactivity as it pertains to Shiny.
Why Do We Need Reactive Programming?
Reactive programming is a style of programming that focuses on values that change over time and calculations and actions that depend ...
Get Mastering Shiny now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.