Upgrade to Pro — share decks privately, control downloads, hide ads and more …

One-Way Data Flow (in Ruby)

One-Way Data Flow (in Ruby)

A short introduction to one-way data flow and Rbdux, a Ruby library to help implement it.

Joshua Tompkins

August 02, 2016
Tweet

More Decks by Joshua Tompkins

Other Decks in Programming

Transcript

  1. “Flux is an architecture for creating data layers in JavaScript

    applications. It was designed at Facebook along with the React view library. It places a focus on creating explicit and understandable update paths for your application's data, which makes tracing changes during development simpler and makes bugs easier to track down and fix.”
  2. Flux is about managing state. If your application state is

    easy to reason about, your application is easy to reason about.
  3. “computers. . . have very large numbers of states. This

    makes conceiving, describing, and testing them hard. Software systems have orders-of-magnitude more states than computers do.” FRED BROOKS 1986
  4. it 'adds a todo item' do a = NewTodoAction.with_payload('test') Rbdux::Store.dispatch(a)

    expect(Rbdux::Store.state) .to eq({ todos: ['test'] }) end
  5. require ‘net/http' Rbdux::Store.before(&Rbdux::Middleware .dispatch_interceptor) Rbdux::Action.define('get_data') do |store, action| uri =

    URI('http://example.com/todos') data = Net::HTTP.get(uri) DataRetrievedAction.with_payload(data) end Rbdux::Action.define('data_retrieved')
  6. NO