1.1.0 • Published 4 years ago

@disco/signals v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

@disco/signals

CI status Coverage Status npm package Dependencies MIT License

This is a middleware for disco to add a signal emitter to each model class which allows monitoring lifecycle events.

Install

npm install @disco/signals

Usage

const disco = require('@disco/disco')
const signals = require('@disco/signals')

const modeller = disco(driver)
modeller.use(signals)

const User = modeller.createModel('user')

// Remember to hash your passwords!
User.signals.on('validate', user => {
  const { password } = user
  user.hash = hash(password)
  delete user.password
})