NPM
npm install flowthings-angular
Bower
bower install flowthings-angular
Dependencies:
angular.module('app', ['flowthings'])
.config(function(flowthingsProvider) {
flowthingsProvider.options.account = '<account_name>';
flowthingsProvider.options.token = '<token>';
})
.run(function($log, flowthings) {
// Connect to WebSockets
flowthings.ws.connect().then(function() {
$log.log('Connected');
});
})
.controller('MainCtrl', function($scope, flowthings) {
$scope.drops = [];
$scope.path = '/my/flow/path';
// Subscribe to Drops
var sub = flowthings.ws.subscribe($scope.path, function(drop) {
$scope.drops.push(drop);
});
// Query for the Flow
flowthings.flow.find({ filter: { path: $scope.path }}).then(function(flow) {
$scope.flow = flow;
});
});accounttoken
Initiates a WebSocket connection. Returns a Promise.
Subscribes to the provided Flow and invokes the callback when receiving Drops. Providing a scope will tie the subscription to the scope's lifecycle, automatically unsubscribing when the scope is destroyed.
Returns a record of { unsubscribe: function, result: Promise }
Sends arbitrary commands through the WebSocket API. Returns a Promise with the response.
Aggregation spec options:
filtergroupByrulesoutputsorts
Please visit the flowthings.io aggregation documentation for more details on how to use these options.
Broadcasted when a WebSocket connection opens. Returns the WebSocket client.
Broadcasted when a WebSocket connection errors. Returns nothing.
Broadcasted when a WebSocket connection closes. Returns WebSocket event object.