mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-08-07 03:24:37 +02:00
global state store
This commit is contained in:
parent
8493b51ec2
commit
e03bdc619f
5 changed files with 95 additions and 12 deletions
|
@ -7,7 +7,6 @@ var EventEmitter = require('events').EventEmitter;
|
|||
var assign = require('object-assign');
|
||||
|
||||
var ActionTypes = AppConstants.ActionTypes;
|
||||
var CHANGE_EVENT = 'change';
|
||||
var DEFAULT_LOCALE = 'en_US';
|
||||
|
||||
// resolve the messy mapping between browser language
|
||||
|
@ -50,8 +49,11 @@ function _getLocaleFromHeader(langString) {
|
|||
}
|
||||
|
||||
var _locale = DEFAULT_LOCALE;
|
||||
var LocaleStore = assign({}, EventEmitter.prototype, {
|
||||
|
||||
var LocaleStore = assign(
|
||||
{},
|
||||
EventEmitter.prototype,
|
||||
AppConstants.StoreSubscribePrototype,
|
||||
{
|
||||
getDefaultLocale: function() {
|
||||
return DEFAULT_LOCALE;
|
||||
},
|
||||
|
@ -64,14 +66,6 @@ var LocaleStore = assign({}, EventEmitter.prototype, {
|
|||
return assign({}, headerLocaleMap);
|
||||
},
|
||||
|
||||
subscribe: function(cb) {
|
||||
this.on(CHANGE_EVENT, cb);
|
||||
},
|
||||
|
||||
unsubscribe: function(cb) {
|
||||
this.removeListener(CHANGE_EVENT, cb);
|
||||
},
|
||||
|
||||
getLocale: function() {
|
||||
return _locale;
|
||||
},
|
||||
|
@ -95,7 +89,7 @@ var LocaleStore = assign({}, EventEmitter.prototype, {
|
|||
}
|
||||
|
||||
if (shouldInform) {
|
||||
LocaleStore.emit(CHANGE_EVENT);
|
||||
LocaleStore.emit(AppConstants.CHANGE_EVENT);
|
||||
}
|
||||
})
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue