Events

Overview

Events are generated when specific things happen i.e. new user has registered or some user added new item. It was created to separate core from user custom logic. It can be used for email notification, logging or changing application default behaviour.

All custom events are located in ./src/listeners/ and they are returing Promise.

Users

emitter.on('user.registration_success', function(user) {
  log.info('user "' + user.email + '" registered successfully');
})

emitter.on('user.login_success', function(user) {
  log.info('user "' + user.email + '" has logged in successfully');
})

Items

emitter.on('item.view', function(item, user) {
  log.info('item id: "%s" and name: "%s" is previewed', item.id, item.name);
})

emitter.on('item.created', function(item, user) {
  log.info('item id: "%s" and name: "%s" was added', item.id, item.name);
})

Subscribers

emitter.on('subscriber.created', function(subscriber) {
  log.info('new subscriber: "%s"', subscriber.email)
})
Was this page helpful ?