mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-07-07 13:14:25 +02:00
global state store
This commit is contained in:
parent
8493b51ec2
commit
e03bdc619f
5 changed files with 95 additions and 12 deletions
42
src/js/stores/GlobalStateStore.js
Normal file
42
src/js/stores/GlobalStateStore.js
Normal file
|
@ -0,0 +1,42 @@
|
|||
"use strict";
|
||||
|
||||
var AppConstants = require('../constants/AppConstants');
|
||||
var AppDispatcher = require('../dispatcher/AppDispatcher');
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
|
||||
var assign = require('object-assign');
|
||||
|
||||
var ActionTypes = AppConstants.ActionTypes;
|
||||
|
||||
var _isAnimating = false;
|
||||
|
||||
var GlobalStateStore = assign(
|
||||
{},
|
||||
EventEmitter.prototype,
|
||||
AppConstants.StoreSubscribePrototype,
|
||||
{
|
||||
getIsAnimating: function() {
|
||||
return _isAnimating;
|
||||
},
|
||||
|
||||
dispatchToken: AppDispatcher.register(function(payload) {
|
||||
var action = payload.action;
|
||||
var shouldInform = false;
|
||||
|
||||
switch (action.type) {
|
||||
case ActionTypes.CHANGE_IS_ANIMATING:
|
||||
_isAnimating = action.isAnimating;
|
||||
shouldInform = true;
|
||||
break;
|
||||
case ActionTypes.CHANGE_FLIP_TREE_Y:
|
||||
break;
|
||||
}
|
||||
|
||||
if (shouldInform) {
|
||||
GlobalStateStore.emit(AppConstants.CHANGE_EVENT);
|
||||
}
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
module.exports = GlobalStateStore;
|
Loading…
Add table
Add a link
Reference in a new issue