mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-07-21 11:15:38 +02:00
[Flux] Initial flux land
This commit is contained in:
parent
5df3d43c4f
commit
eba404c595
5 changed files with 105 additions and 3 deletions
42
src/js/stores/LocaleStore.js
Normal file
42
src/js/stores/LocaleStore.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 CHANGE_EVENT = 'change';
|
||||
|
||||
var _locale = 'en_US';
|
||||
var LocaleStore = assign({}, EventEmitter.prototype, {
|
||||
|
||||
subscribe: function(cb) {
|
||||
this.on(CHANGE_EVENT, cb);
|
||||
},
|
||||
|
||||
unsubscribe: function(cb) {
|
||||
this.removeListener(CHANGE_EVENT, cb);
|
||||
},
|
||||
|
||||
getLocale: function() {
|
||||
return _locale;
|
||||
},
|
||||
|
||||
dispatchToken: AppDispatcher.register(function(payload) {
|
||||
var action = payload.action;
|
||||
var shouldInform = false;
|
||||
|
||||
switch (action.type) {
|
||||
case ActionTypes.CHANGE_LOCALE:
|
||||
}
|
||||
|
||||
if (shouldInform) {
|
||||
this.emit(CHANGE_EVENT);
|
||||
}
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
module.exports = LocaleStore;
|
Loading…
Add table
Add a link
Reference in a new issue