0.0.7 • Published 9 years ago

react-capacitor v0.0.7

Weekly downloads
2
License
MIT
Repository
github
Last release
9 years ago

react-capacitor

Flux store, and dispatcher.

Example Usage

npm install --save react-capacitor
var Dispatcher = require('react-capacitor/lib/Dispatcher');
var AppDispatcher = new Dispatcher();

###Trigger an action in the view

AppDispatcher.triggerAction('signup', {
  email: 'emmett.brown@1985.com',
  name: 'Emmett'
});

###Binding to actions

AppDispatcher.onAction('signup', function(data) {
  UserStore.setProperties({
    email: data.email,
    name: data.name
  });
  // automatically emits the change event, but only when the data is different
});

Create a store and set the default

var Store = require('react-capacitor/lib/Store');

var UserStore = new Store({
  // Default values
  email: '',
  name: ''
});

###Managing the store

// Set a single value
UserStore.set('email', 'marty.mcfly@1985.com');

// Set multiple values
UserStore.setProperties({name: 'Marty McFly', car: 'Delorean'});

// Reset and set multiple values
UserStore.setAll({name: 'Doc Brown'});

// Reset values
UserStore.reset();

###Getting store data

// Get a single value
UserStore.get('email');

// Get multiple values
UserStore.getProperties('email', 'name');

// Get all values
UserStore.getAll();

###Binding to change events on a React component

...

componentWillUnmount: function() {
  UserStore.on('change', this._change);
},

componentWillUnmount: function() {
  UserStore.removeListener('change', this._change);
},

...
0.0.7

9 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago