Created
May 23, 2014 22:58
-
-
Save jmreidy/c41f666a20da439594d3 to your computer and use it in GitHub Desktop.
A Flux store built on ImmutableFluxStore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** @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