hashDriver.js 362 B

12345678910
  1. var Rx = require('cyclejs').Rx;
  2. module.exports = function(outgoing$) {
  3. outgoing$.subscribe(function(newHash) {
  4. window.location.hash = newHash;
  5. });
  6. return Rx.Observable.fromEvent(window, 'hashchange')
  7. .map(function(hashEvent) { return hashEvent.target.location.hash.replace('#', '') })
  8. .startWith(window.location.hash.replace('#', '') || '')
  9. }