safe-event-emitter

An `EventEmitter` that isolates the emitter from errors in handlers. If an error is thrown in a handler it is caught and re-thrown inside of a `setTimeout` so as to not interupt the emitter's code flow.

Renamed to @metamask/safe-event-emitter
Last updated 8 years ago by kumavis .
ISC · Original npm · Tarball · package.json
$ cnpm install safe-event-emitter 
SYNC missed versions from official npm registry.

safe-event-emitter

An EventEmitter that isolates the emitter from errors in handlers. If an error is thrown in a handler it is caught and re-thrown inside of a setTimeout so as to not interupt the emitter's code flow.

API is the same as EventEmitter.

usage

const SafeEventEmitter = require('safe-event-emitter')

const ee = new SafeEventEmitter()
ee.on('boom', () => { throw new Error() })
ee.emit('boom') // no error here

// error is thrown after setTimeout

Current Tags

  • 1.0.1                                ...           latest (8 years ago)

2 Versions

  • 1.0.1 [deprecated]           ...           8 years ago
  • 1.0.0 [deprecated]           ...           8 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (0)
None

Copyright 2013 - present © cnpmjs.org | Home |