UNPKG

react-crossroads

Version:

Client side router for web applications built with React and utilizing the Flux architecture. The backing routing engine is CrossroadsJs.

40 lines (28 loc) 688 B
invariant = require('react/lib/invariant') _onChange = null # Location handler that does not require a DOM. MemoryLocation = setup: (onChange) -> _onChange = onChange push: (path) -> _lastPath = _currentPath _currentPath = path _onChange() replace: (path) -> _currentPath = path _onChange() pop: -> invariant( _lastPath != null, 'You cannot use MemoryLocation to go back more than once' ) _currentPath = _lastPath _lastPath = null _onChange() getCurrentPath: -> _currentPath isSupportedOrFallback: -> true pathToHref: (path) -> path toString: -> '<MemoryLocation>' module.exports = MemoryLocation