Skip to content

Simple asynchronous emitter and event observer for sails v1.x

License

Notifications You must be signed in to change notification settings

Sacrize/sails-hook-custom-events

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sails Hook Custom Events

Simple asynchronous emitter and event observer thanks to the emittery library.

Getting Started

Install it via npm:

npm install sails-hook-custom-events --save

Create a directory structure:

.
├── api/
│   ├── ...
│   ├── observers/
│   │   ├── event-name-1/
│   │   │   ├── observer-name-1.js
│   │   │   ├── observer-name-2.js
│   │   │   └── ... 
│   │   ├── event-name-2/
│   │   └── ... 
|   └── ... 
└── ...

Events and observers are automatically discovered based on the directory structure. Their names can be anything.

Observer is a function:

module.exports = function (data) {

};

Emitting an event:

sails.hooks.events.emit('event-name-1', { ... });

License

MIT

About

Simple asynchronous emitter and event observer for sails v1.x

Resources

License

Stars

Watchers

Forks

Packages

No packages published