react-crossroads
Version:
Client side router for web applications built with React and utilizing the Flux architecture. The backing routing engine is CrossroadsJs.
44 lines (39 loc) • 939 B
JavaScript
var MemoryLocation, invariant, _onChange;
invariant = require('react/lib/invariant');
_onChange = null;
MemoryLocation = {
setup: function(onChange) {
return _onChange = onChange;
},
push: function(path) {
var _currentPath, _lastPath;
_lastPath = _currentPath;
_currentPath = path;
return _onChange();
},
replace: function(path) {
var _currentPath;
_currentPath = path;
return _onChange();
},
pop: function() {
var _currentPath, _lastPath;
invariant(_lastPath !== null, 'You cannot use MemoryLocation to go back more than once');
_currentPath = _lastPath;
_lastPath = null;
return _onChange();
},
getCurrentPath: function() {
return _currentPath;
},
isSupportedOrFallback: function() {
return true;
},
pathToHref: function(path) {
return path;
},
toString: function() {
return '<MemoryLocation>';
}
};
module.exports = MemoryLocation;