Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

choo-hooks

Package Overview
Dependencies
Maintainers
27
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

choo-hooks

Hook into Choo's events and timings

  • 1.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
27
Created
Source

choo-hooks stability

npm version build status downloads js-standard-style

Hook into Choo's events and timings. Useful to create loggers, analytics and more.

Usage

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)
  })
})

API

hooks = Hooks(emitter)

Create a new Choo Hooks instance.

hook.on('log:trace', cb(…args))

hook.on('log:debug', cb(…args))

hook.on('log:info', cb(…args))

hook.on('log:warn', cb(…args))

hook.on('log:error', cb(…args))

hook.on('log:fatal', cb(…args))

Listen for log events.

hook.on('service-worker', cb(data))

Listen for service worker event.

hook.on('event', cb(eventName, timing, data))

Called for events implemented at the application layer.

hook.on('unhandled', cb(eventName, data))

Called whenever an event is emitted, and there is no handler available.

hook.on('DOMContentLoaded', cb(timing))

Called whenever the DOM has loaded. Returns the window.performance.timing object.

hook.on('render', cb(timings))

Called whenever Choo renders. Returns an object with the render and morph properties.

hook.on('resourceTimingBufferFull', cb())

Called whenever the browser's resource timing buffer has filled up.

License

MIT

Keywords

FAQs

Package last updated on 23 Mar 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc