Explain Reactive Programming Like I'm Five

I'm still having problems comprehending Reactive Programming. Thanks in advance for the help. :)

Did you find this post useful? Show some love!

Reactive programming is like the infamous "marble course" we all loved to play with as kids:

marble course

Instead of dictating what your code should do RIGHT NOW (procedural programming), you define what may happen in response to a certain set of events, like where you may have several "entry pipes" in your marble course!.

Imagine walking into coffee shop and ordering a cappuccino. The barista takes your order and starts making the coffee. Other customers wait patiently behind you in line till your coffee is prepared and you pay. The barista then deals with the next customer. This is imperative style coding.

Now, imagine walking into a coffee shop and ordering a cappuccino. The barista takes your order and hands you a token. He shouts to his minions saying "Token 42, Cappuccino, no sugar". You are asked to wait comfortably on a couch. The barista then deals with the next customer. Whenever your coffee is ready, he shouts "Token 42, Cappuccino, no sugar, ready!". You show your token, pick up the coffee and walk out. Other customers do the same. That's reactive programming. You reacted to a set of events and didn't wait till a process was complete.

If you've ever made a formula in Excel, you've done reactive programming.

If you put =A1+B1 in the cell C1, you're saying you want C1 to be updated every time A1 or B1 is updated. That's also what you do in reactive programming.

Or, in other words: this value is based on changes from these other values.

Classic DEV Post from Feb 5

A toddlers guide to memory leaks in Javascript

A guide to understanding memory in Javascript

READ POST
Follow @kepta to see more of their posts in your feed.
John Paul Ada
BA Psychology grad turned software engineer @ GAPLabs. Tech Evangelist. Data Scientist Wannabe.
More from @johnpaulada
Explain Backpropagation like I'm Five
#explainlikeimfive #deeplearning #backpropagation #discuss
Explain GraphQL like I'm five.
#explainlikeimfive #discuss #graphql
Trending on dev.to
Log and Exponential for Programmers
#explainlikeimfive #beginners #algorithms
How much should you refactor names when domain terminology changes?
#discuss #refactoring
What are your programming hype songs?
#discuss #music #productivity
Why I love hiring Junior engineers
#engineers #culture #career
When to give a star to an open source library?
#opensource #developers #community #discuss
Why do people like Ruby?
#discuss #ruby
How did you learn to flex your CSS muscles?
#discuss #css #frontend #react
How frequently do you code?
#dailywork #job #career #discuss