SHARE
TWEET

Untitled

a guest Sep 7th, 2014 666 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var merge = require('react/lib/merge');
  2. var EventEmitter = require('events').EventEmitter;
  3.  
  4. var _state = {};
  5. var _EVENT_CHANGE = 'testing:change';
  6.  
  7. module.exports = merge(EventEmitter.prototype, {
  8.   get: function(name) {
  9.     return name ? _state[name] : _state;
  10.   },
  11.   set: function(name, value) {
  12.     _state[name] = value;
  13.     var arg = {};
  14.     arg[name] = value;
  15.     this.emitChange(arg);
  16.   },
  17.   addChangeListener: function(callback) {
  18.     this.on(_EVENT_CHANGE, callback);
  19.   },
  20.   removeChangeListener: function(callback) {
  21.     this.removeListener(_EVENT_CHANGE, callback);
  22.   },
  23.   emitChange: function(arg) {
  24.     this.emit(_EVENT_CHANGE, arg);
  25.   }
  26. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top