No commit activity in last 3 years
No release in over 3 years
Use Facebook's Flux dispatcher and Node EventEmitter in your Rails project.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 3.2.12

Runtime

>= 3.1
 Project Readme

flux-rails-assets

Flux and Node EventEmitter for Rails Asset Pipeline for use with react-rails gem

Doesn't use CommonJS instead it creates FluxDispatcher and EventEmitter on window to easily work with sprockets-rails Assets Pipeline.

Works well with react-rails server side rendering.

Installation

Add this line to your application's Gemfile:

gem 'flux-rails-assets'

And then execute:

$ bundle

Or install it yourself as:

$ gem install flux-rails-assets

Usage

Require flux and the eventemitter in your application.js:

//= require flux
//= require eventemitter

This will create two globals you can use to create your application's dispatcher and stores:

var AppDispatcher = new Flux.Dispatcher();

var ExampleStore = new EventEmitter();

ExampleStore.dispatchToken = AppDispatcher.register(function (payload) {
  var action = payload.action;

  switch(action.actionType) {

    case 'EXAMPLE_ACTION':
      ExampleStore.emit('change');
      break;

    default:
      // do nothing
  }
});

Credits

Flux by Facebook Node EventEmitter by Joyent

Written by Stefan Ritter, released under the MIT license.