Skip to content

About

Basic Dispatcher based on Facebook's Flux architecture

Resources

Stars

1 star

Watchers

4 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#Flux Dispatcher

A basic Dispatcher based on Facebook's Flux architecture.

##Usage

var Dispatcher = require('compose-flux-dispatcher')
  , my_dispatcher = new Dispatcher()

my_dispatcher.register(function() {
/* 
  This will get called _everytime_ 
  my_dispatcher.dispatch() is 
*/
})

my_dispatcher.dispatch(/* data you want to dispatch */)

##Caveats and Conventions

In true Flux fashion there is only one dispatcher. You can instantiate as many as you like within the same process but all dispatches will be shared to all registered callbacks. Instead, favor filtering by the payload in your callbacks.

my_dispatcher.register(function(payload) {
  if (payload.source !== 'pugs')
    return

  /* Continue execution */
})

Use multiple instantiations for simplifying payloads

var pug_dispatcher = new Dispatcher()

pug_dispatcher.send_pug = function(pug_name) {
  this.dispatch({
    source: 'pugs',
    name: pug_name
  })
}

About

Basic Dispatcher based on Facebook's Flux architecture

Resources

Stars

1 star

Watchers

4 watching

Forks

Releases

Packages

Used by

Contributors

Languages