Technology

The Dispatcher as a Stream, Part 1: FRP && ReactJS


If you look at the existing Flux architecture, at the 10,000ft level, it already uses functional reactive programming.

  • The Dispatcher is an Observable accepting inputs (Actions)
  • The Dispatcher re-emits Actions to its Observers.
  • Stores observe the Dispatcher and act accordingly.

We can thus replace the Dispatcher with an Observable that accepts inputs. In BaconJS, for example, it’s called a Bus. The Dispatcher is just this in FRP:

//AppDispatcher.js
import Bacon from 'baconjs'

export default new Bacon.Bus()

Actions can look like this:

//TodoActions.js
import AppDispatcher from 'AppDispatcher'

export default {

  addTodo: function(todo) {

    AppDispatcher.push({
       channel: 'todo',
       actionType: 'create',
       data: todo
   })
 }    
}

So far, the FRP ReactJS app looks like a run-of-the-mill Flux app. Things get interesting when we get to Stores…

By the way, we use a single global dispatcher to reap the benefits of FRP—the Actions passed to the Dispatcher plus the states of the stores completely define the App state at any moment in time. We can therefore easily replay the state of the App (for debugging). Did I also mention we get undo functionality for free? Pretty. Freakin’. Cool.

Technology

Functional Reactive Programming in JS, the 10,000ft Overview


I’ve spent the past year working with functional reactive programming (FRP). Some of the problems I’ve noticed is that most of the online resources either:

  • assumes you already know what FRP is
  • assumes you won’t create anything more complex than a toy app
  • focuses on the “reactive” part, ignoring the functional programming

Let’s fix that by answering, “What is functional programming (FP)?””
Continue reading

Technology

How to Implement the Backpropagation Algorithm


Unfortunately, typesetting math in WordPress.com is painful, painful, painful
So instead battling WordPress, I’m gonna use my notebook for this post.

As usual, there is code! https://github.com/frankandrobot/mustached-octo-neuralnetwork

(Oh and as of 12/8/2013, my notebook is visually ugly. Will style it later.)