UNPKG

diffusion

Version:

Diffusion JavaScript client

52 lines (50 loc) 1.52 kB
var _interface = require('util/interface')._interface; var Stream = require('./stream'); /** * Provides a stream of topic values for a given fetch request. * <P> * FetchStream inherits all functions defined on {@link Stream}. * <P> * <br/> * * @example * // Handle all events from stream * session.fetch("foo").on({ * open : function() { * // Fetch stream has opened, values will be emitted after this event. * }, * value : function(value, topicPath) { * // Received topic value * }, * error : function(err) { * // Encountered an error * }, * close : function() { * // Fetch stream closed; no more values will be received * } * }); * * @class FetchStream * * @fires Stream#error * @fires Stream#close * @fires FetchStream#open * @fires FetchStream#value * * @augments Stream */ module.exports = _interface('FetchStream', Stream, [ /** * Emitted when the fetch stream is initially opened. This will only be fired once. * * @event FetchStream#open */ /** * Emitted when a topic that is selected by the fetch request's topic selector has returned its value. By default, * values are provided as <code>Buffer</code> instances. The topic path specifies which topic this value is for. * * @event FetchStream#value * @property {Buffer} value - the new value of the topic * @property {String} topicPath - the path to the topic to which the value update applies */ ]);