Produce a route object that specifies both an enter
and an exit
hook
given either a function to be used as the sole "enter" hook, or an object
that defines one or both hooks.
import { withHooks } from 'page-fu';
assertHasBothHooks(withHooks(function myEnter(ctx, next) {}))
assertHasBothHooks(withHooks({ enter() {} }))
assertHasBothHooks(withHooks({ exit() {} }))
function assertHasBothHooks(route) {
console.assert(typeof route === 'object')
console.assert(typeof route.enter === 'function')
console.assert(typeof route.exit === 'function')
}
spec | Function|Object |
route | Object |
route.enter | Function |
route.exit | Function |
The enter
routine that gets called when the route is activated.
ctx | page.Context |
next | Function Call this if you do not want to activate the route and instead forward to the next one. |
The routine that gets called when the route is about to become deactivated.
ctx | page.Context page.js context object. |
next | Function Function to invoke when you're done cleaning up. If you do not call this, the route will never be exited. |