hooksjs
v0.0.2
Published
Generic Hooks and Triggers
Downloads
2
Readme
hooksjs
Generic Hooks and Triggers
Runs a stack of new functions before or after (pre / post) of the original function
Install
npm install hoohsjs
See live example:
Examples
Write some code
class Model {
save() {
return { success: true };
}
}
const model = new Model();
Wrap it
const modelHooks = new Hooks(model);
Add some hooks pre / post
modelHooks
.pre('save', preSave1)
.pre('save', preSave2);
modelHooks
.post('save', postSave1)
.post('save', postSave2);
Run it, the pre and post stack makes magic
model.save();