virgilio-on

0.1.0 • Public • Published

Virgilio-on

Event-driven actions for virgilio

Usage

Lets say we have a blinkLight and sendPush action on our Doorbell namespace.

var Doorbell = virgilio.namespace$('modules.doorbell');
Doorbell.defineAction$(function blinkLight() {
	console.log('Blink HUE light');
	// return Utils.hue.blink(...).then(func..{});
});
Doorbell.defineAction$(function sendPush() {
	console.log('Send RING RING push message');
	// return Utils.push.send(...).then(func..{});
});

We want these actions to run when a specific event is triggered, for example 'doorbell'. To make this happen we can assign an event to them.

Doorbell.blinkLight.on('doorbell');
Doorbell.sendPush.on('doorbell');

Now, when we send the 'doorbell' event the actions will run.

// Lets assume we have a virgilio instance
virgilio.emit('doorbell');

There is a working example of the above in the examples directory.

Readme

Keywords

Package Sidebar

Install

npm i virgilio-on

Weekly Downloads

1

Version

0.1.0

License

none

Last publish

Collaborators

  • rolfkoenders