$ cnpm install @metamask/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 interrupt the emitter's code flow.
The API is the same as a core EventEmitter.
$ yarn add '@metamask/safe-event-emitter'
import SafeEventEmitter from '@metamask/safe-event-emitter';
const ee = new SafeEventEmitter();
ee.on('boom', () => { throw new Error(); });
ee.emit('boom'); // No error here
// Error is thrown after setTimeout
The project follows the same release process as the other libraries in the MetaMask organization:
master1.x)yarn version --minor --no-git-tag-version)yarn test
Copyright 2013 - present © cnpmjs.org | Home |