listen to hash changes

This commit is contained in:
timwis
2016-06-04 18:00:00 -04:00
parent a1be33269d
commit 97d7122ff2
2 changed files with 11 additions and 1 deletions
+9
View File
@@ -2,6 +2,8 @@ const history = require('sheet-router/history')
const sheetRouter = require('sheet-router')
const document = require('global/document')
const href = require('sheet-router/href')
const hash = require('sheet-router/hash')
const hashMatch = require('hash-match')
const sendAction = require('send-action')
const mutate = require('xtend/mutable')
const assert = require('assert')
@@ -205,6 +207,13 @@ function appInit (opts) {
// enable HTML5 history API
if (opts.href !== false) pushLocationSub(href)
if (opts.history !== false) pushLocationSub(history)
if (opts.hash !== false) {
pushLocationSub(function (navigate) {
hash(function (fragment) {
navigate(hashMatch(fragment))
})
})
}
return model
+2 -1
View File
@@ -20,8 +20,9 @@
"license": "MIT",
"dependencies": {
"global": "^4.3.0",
"hash-match": "^1.0.2",
"send-action": "^1.1.0",
"sheet-router": "^3.0.0",
"sheet-router": "^3.1.0",
"xhr": "^2.2.0",
"xtend": "^4.0.1",
"yo-yo": "^1.2.0"