@@ -6,6 +6,7 @@ const href = require('sheet-router/href')
|
|||||||
const hash = require('sheet-router/hash')
|
const hash = require('sheet-router/hash')
|
||||||
const hashMatch = require('hash-match')
|
const hashMatch = require('hash-match')
|
||||||
const barracks = require('barracks')
|
const barracks = require('barracks')
|
||||||
|
const nanoraf = require('nanoraf')
|
||||||
const assert = require('assert')
|
const assert = require('assert')
|
||||||
const xtend = require('xtend')
|
const xtend = require('xtend')
|
||||||
const yo = require('yo-yo')
|
const yo = require('yo-yo')
|
||||||
@@ -22,6 +23,7 @@ function choo (opts) {
|
|||||||
var _defaultRoute = null
|
var _defaultRoute = null
|
||||||
var _rootNode = null
|
var _rootNode = null
|
||||||
var _routes = null
|
var _routes = null
|
||||||
|
var _frame = null
|
||||||
|
|
||||||
start.toString = toString
|
start.toString = toString
|
||||||
start.router = router
|
start.router = router
|
||||||
@@ -85,8 +87,13 @@ function choo (opts) {
|
|||||||
opts.onStateChange(data, state, prev, name, createSend)
|
opts.onStateChange(data, state, prev, name, createSend)
|
||||||
}
|
}
|
||||||
|
|
||||||
const newTree = _router(state.location.pathname, state, prev)
|
if (!_frame) {
|
||||||
_rootNode = yo.update(_rootNode, newTree)
|
_frame = nanoraf(function (state, prev) {
|
||||||
|
const newTree = _router(state.location.pathname, state, prev)
|
||||||
|
_rootNode = yo.update(_rootNode, newTree)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
_frame(state, prev)
|
||||||
}
|
}
|
||||||
|
|
||||||
// register all routes on the router
|
// register all routes on the router
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
"document-ready": "~1.0.2",
|
"document-ready": "~1.0.2",
|
||||||
"global": "^4.3.0",
|
"global": "^4.3.0",
|
||||||
"hash-match": "^1.0.2",
|
"hash-match": "^1.0.2",
|
||||||
|
"nanoraf": "^2.0.0",
|
||||||
"sheet-router": "^3.1.0",
|
"sheet-router": "^3.1.0",
|
||||||
"xhr": "^2.2.0",
|
"xhr": "^2.2.0",
|
||||||
"xtend": "^4.0.1",
|
"xtend": "^4.0.1",
|
||||||
|
|||||||
Reference in New Issue
Block a user