Skip to content

Instantly share code, notes, and snippets.

@jmreidy
Created May 23, 2014 22:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmreidy/c41f666a20da439594d3 to your computer and use it in GitHub Desktop.
Save jmreidy/c41f666a20da439594d3 to your computer and use it in GitHub Desktop.
A Flux store built on ImmutableFluxStore
/** @jsx React.DOM */
var director = require('director');
var Dispatcher = require('../Dispatcher');
var HistoryConstants = require('../constants/HistoryConstants');
var ImmutableFluxStore = require('ImmutableFluxStore');
var _initializeRouter = function (store) {
return director.Router({
'/admin/login': function () {
store.set('page', 'LoginPage');
},
}).configure({
html5history: true,
});
};
var HistoryStore = function () {
this.router = _initializeRouter(this);
this.dispatcher = Dispatcher;
ImmutableFluxStore.call(this);
};
ImmutableFluxStore.extend(HistoryStore, {
actions: {
'handleNavigate': [HistoryConstants.HISTORY_NAVIGATE, function (payload) {
this.router.setRoute(payload.url);
}],
'handleInitialize': [HistoryConstants.HISTORY_START, function (payload) {
this.router.init();
}]
}
});
module.exports = new HistoryStore();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment