Skip to content

About

flux-rails-assets gem

Resources

Stars

18 stars

Watchers

2 watching

Forks

Latest commit

 

History

13 Commits

Folders and files

Repository files navigation

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.

About

flux-rails-assets gem

Resources

Stars

18 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages