Last active
August 29, 2015 14:07
-
-
Save 13protons/24fed8fd5ff853ff0855 to your computer and use it in GitHub Desktop.
Mock Button
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){ | |
console.log(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) { | |
config | |
.state('ready') | |
.type('button') | |
.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