Hook into Choo's events and timings. Useful to create loggers, analytics and more.
var Hooks = require('choo-hooks')
var choo = require('choo')
var app = choo()
app.use(function (state, emitter) {
var hooks = Hooks(emitter)
hooks.on('event', function (eventName, timing, data) {
console.log(eventName + ':', timing.duration + 'ms', data)
})
hooks.on('unhandled', function (eventName, data) {
console.error('No listeners for ' + eventName)
})
})
Create a new Choo Hooks instance.
Listen for log events.
Listen for service worker event.
Called for events implemented at the application layer.
Called whenever an event is emitted, and there is no handler available.
Called whenever the DOM has loaded. Returns the window.performance.timing
object.
Called whenever Choo renders. Returns an object with the render
and morph
properties.
Called whenever the browser's resource timing buffer has filled up.