DEV Community

Discussion on: Explain Reactive Programming Like I'm Five

Collapse
 
mohanarpit profile image
Arpit Mohan

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.