-
-
Save mdobson/76466413160a795d7e0c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(server) { | |
var buttonQuery = server.where({type: 'button'}); | |
server.observe([buttonQuery], function(button){ | |
button.on('click', function(b){ | |
//This will log undefined because there are no inputs to this transition | |
//You can use dot notation to access properties on devices | |
//console.log(b); | |
console.log(button.b); | |
}) | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Device = require('zetta').Device; | |
var util = require('util'); | |
var Button = module.exports = function(n) { | |
Device.call(this); | |
this.name = n || 'Button'; | |
}; | |
util.inherits(Button, Device); | |
Button.prototype.init = function(config) { | |
//Name is set in here. | |
config | |
.state('ready') | |
.type('button') | |
.name(this.name) | |
.when('ready', { allow: ['click'] }) | |
.map('click', this.Click); | |
}; | |
Button.prototype.Click = function(cb) { | |
cb(); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var zetta = require('zetta'); | |
var Button = require('./devices/button'); | |
var app = require('./apps/app.js'); | |
zetta() | |
.use(Button, 'Lights') | |
.use(Button, 'Camera') | |
.use(app) | |
.listen(1337); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment