:metal: KnockoutJS Goodies Monorepo
ES2015
import { Router } from '@profiscience/knockout-contrib'
CommonJS
const { Router } = require('@profiscience/knockout-contrib')
Browser Globals
const { Router } = ko.router
Current router context object
Promise that returns after this router is initialized
Depth of this router; accessor for router.ctx.$parents.length
Observable value that is true if router is navigating
Is the root router
Routes to path
; adds history state entry if push === true
Second argument can be a boolean push
, or an options object:
Option | Description | Default |
---|---|---|
push | push history state entry | true |
force | force reload of same route | false |
with | object to extend context with | {} |
Return router at the given depth, beginning at 0
Top-most router
Alias for Router.head.initialized
Observable value which is true if any routers are navigating, including nested routers
Sets router configuration. See Basic Usage for more.
Registers app middleware
Registers plugin. Use Route.usePlugin
instead.
Plugins must be registered before routes
Registers routes
NOTE: setConfig
and the use
methods may be chained, e.g.
Router.setConfig(routerConfig)
.use(someMiddleware)
.use(anotherMiddleware)
.usePlugin(somePlugin)
.useRoutes(homeRoutes)
.useRoutes(profileRoutes)
Convenience function for Router.get(0).update(...)