Insights

Functional Reactive JavaScript Programming w/ Bacon.js

2 min readJoe Hanson on Oct 16, 2014
Try PubNub Today

Free up to 1MM monthly messages. No credit card required.

Subscribe to our newsletter

By submitting this form, you are agreeing to our Terms and Conditions and Privacy Policy.

The blog post looks at the core concepts of functional reactive JavaScript programming, as well as practical applications of it with Bacon.js.

reactive javascriptThe re-emergence of functional programming coincides nicely with the JavaScript renaissance. But where does the UI fit in?

Pete Hodgson of ThoughtWorks dropped by PubNub HQ for San Francisco JavaScript to answer just that. In his talk, Pete covers the core concepts of functional reactive JavaScript programming, while learning a practical application of them using Bacon.js.

He also walked through how to build user interface components in a clear, declarative style by modeling both user interaction and back-end processing using one clean abstraction: stream of events.

As you watch the video below, feel free to click through Pete’s slides. You can also check out the live examples from Pete’s talk here.]

Functional Reactive JavaScript – Pete Hodgson from PubNub on Vimeo.

Variables vs. Streams in Functional Reactive JavaScript Programming

Reactive JavaScript

In a regular JavaScript application, a variable is simply a snapshot of a value at a specific time. If you grab the value of a text field in a DOM element, and store it somewhere, that’s the value of that text field at that moment. If someone changes that text field, the variable doesn’t change, it’s just a snapshot at that point of time.

The innovation of functional reactive programming is we start thinking about things as streams. Streams are all possible future values over time. Say you grab a stream from a text field in a DOM element, you don’t just have the current value, but rather all future values of that text field. And that has major implications of how we program with JavaScript.

More from PubNub

Can Empathy Exist in the Metaverse
News May 16, 20221 min read

Can Empathy Exist in the Metaverse

A roundtable discussion led by PubNub’s COO, Casey Clegg, exploring the topics of what it means to be human in a virtual world.

PubNub Staff

PubNub Staff

How to Advance Telehealth and Virtual Care Technologies
News May 2, 20221 min read

How to Advance Telehealth and Virtual Care Technologies

Dr. Joe Kvedar, Chair of the Board for the American Telemedicine Association, joins our COO, Casey Clegg, to discuss why...

PubNub Staff

PubNub Staff

Another Step Towards Data Security: ISO-27001 Implementation
BuildMay 2, 20221 min read

Another Step Towards Data Security: ISO-27001 Implementation

Today, we are glad to announce that we are currently in the process of implementing ISO-27001 security standards.

PubNub Staff

PubNub Staff