Package Exports
- capillaries
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (capillaries) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Capillaries 
Javascript Events
Getting Started
Installation
Installation can be done via package managers such as npm or yarn
% npm install capillaries
# or
% yarn add capillaries
or use cdn
Minified:
//cdn.jsdelivr.net/npm/capillaries@latest/capillaries.umd.min.js
Pretty Printed:
//cdn.jsdelivr.net/npm/capillaries@latest/capillaries.umd.js
Events
import { Events } from 'capillaries';
const event = new Events();
const listener = function (payload) {
console.log('Event Received:', payload);
};
// create a event listeners
event.on('connecting', listener);
event.on('connected', listener, this); // optionally bind context to the listener when invoked
// dispatch events
event.emit('connected', 'paylod');
// remove a event listener
const unsubscribe = event.on('connected', listener);
unsubscribe();
// remove all listeners for given event
event.off('connected');
// unbind all event listeners
event.unbindAll();
Hooks
import { Hooks } from 'capillaries';
const hooks = new Hooks();
// create a tap
hooks.tap('Hook', () => {
return 'Hello World!';
});
hooks.tap('AsyncHook', async () => {
return 'Hello World!';
});
// Call the taps
hooks.call('Hook', payload); //-> returns undefined
hooks.callWaterFall('Hook', payload); //-> returns 'Hello World!'
hooks.callAsync('AsyncHook', payload); // awaits on taps, returns undefined
hooks.callAsyncWaterFall('AsyncHook', payload); // awaits on taps, returns 'Hello World!'
Hooks are executed in order. The waterfall passes a return value from each function to the next function and returns final retuned data
Browser compatibility
- Internet Explorer 9+
- Chrome 6+
- Edge 12+
- Firefox 4+
- Opera 12+
- Safari 5.1+