
Product
Introducing Socket Firewall Enterprise: Flexible, Configurable Protection for Modern Package Ecosystems
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.
bookshelf-signals
Advanced tools
A Bookshelf plugin that translates all models and collection events to a single hub
The Bookshelf plugin that translates bookshelf events to a central hub. By default that hub is a bookshelf instance itself. That's useful if you want to subscribe to an event but don't want to modify model or collection initializer.
Signals = require 'bookshelf-signals'
db = bookshelf(knex)
db.plugin Signals()
class User extend db.Model
tabeName: 'users'
db.on 'saved', User, ->
console.log 'user was saved!'
db.plugin Signals(hub)
Argument passed to plugin is a hub to that all bookshelf events will be translated. It should at least implement methods trigger and triggerThen. If undefined then events will be translated to bookshelf instance and required methods will be added to it.
Default hub implementation has a behaviour different from EventEmitter. Its methods on, addListener, once, off, removeListener, removeAllListeners accepts class or model/collection name as a second parameter and performs events filtration according to it.
Methods:
on(String event, [(Class|String) cls], Function handler)
Subscribe to event with optional filtration by source class.
addListener - alias for on
removeListener(String event, [(Class|String) cls], Function handler)
Unsubscribe from event. If class/name was used for subscription you have to use the same class/name to unsubscribe.
off - alias for removeListener
once(String event, [(Class|String) cls], handler)
Subscribe to first event of that type and source class, if filtered.
removeAllListeners([String event], [(Class|String) cls])
Unsubscribe all listeners for that event and source class.
FAQs
A Bookshelf plugin that translates all models and collection events to a single hub
We found that bookshelf-signals demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Product
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.

Security News
Open source dashboard CNAPulse tracks CVE Numbering Authorities’ publishing activity, highlighting trends and transparency across the CVE ecosystem.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.