hookies
Hookies is a very simple object specific publish/subscribe library. Hookies allows you to create "as many as you need" independent objects that will enjoy it's own on
|off
and trigger
methods. Let me give you an example:
; { super; thisname = name; } { super; thisname = name; } const tom = 'Tom';const jerry = 'Jerry'; // tom subscribes to `detect-mouse` event.tom; jerry; tom; // This will produce following output://// Tom has detected Jerry// Jerry runs away, because Tom is chasing him.
Installation
As simple as:
npm install hookies
Usage
; const myHookie = ; // Second argument can be optionally and object which will represent `this`// inside a callbackmyHookie; myHookie;// John [1, 2, 3]
Callback functions are executed asynchronously by default, but you can force them to run synchronously too:
; const myHookie = ; myHookie; myHookie; console; myHookie; console; // Bob [1, 2, 3]// I am sync// I am async// John [1, 2, 3]
License
The MIT License (MIT) - See file 'LICENSE' in this project
Copyright
Copyright © 2016 Jiri Chara. All Rights Reserved.