-
Notifications
You must be signed in to change notification settings - Fork 114
Apps
A Zetta app is custom JavaScript code that you implement to query for devices and wire up interations between them. Apps are stateless and run in the context of the Zetta server. Unlike Scouts and Devices, which are JavaScript objects, apps are basic Node.js modules.
This code illustrates a simple query statement (where) and a listener (observe) that takes action whenever the query is satisfied.
module.exports = function(server) {
var arduinoQuery = server.where({type: 'arduino'});
server.observe([arduinoQuery], function(arduino){
//Work with arduino!
});
}
An app is an exported function module that takes a single server
argument. This argument is a reference to a Zetta server instance, and provides all of the context of the server to the app.
module.exports = function(server) {
//app implementation
}
Specifies a SQL-like query that allows the Zetta server query for specific device properties.
Arguments
- query - An object specifying the query to perform. Specifies property/value pairs for devices. All specified device properties are &&'d together.
var query = server.where({ type: 'lcd', id: '123abc' });
A listener that waits for all devices specified in the queries to come online.
Arguments
-
queries - An array of Query objects.
-
callback - A callback function that is called when all devices conforming to the queries are online.
var queryFoo = server.where({type: 'foo'});
var queryBar = server.where({type: 'bar'});
server.observe([queryFoo, queryBar], function(foo, bar){
});
Need help? Visit the Zetta Discuss List !
Need help? Visit the Zetta Discuss List ! |
---|
About Zetta
Videos and webcasts
- NEW! Building with Zetta
Tutorials
- NEW! Zetta tutorial series
- Quick start
- Configure a simple device
- Build a mock LED device
- Use the browser client
- Deploy a Zetta server to Heroku
Understanding Zetta
Writing Zetta drivers
- Finding Zetta device drivers
- Create a device driver from starter code
- More coming soon...
Using streams
Reference