Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface FetchStream

Provides a stream of topic values for a given fetch request.

FetchStream inherits all functions defined on Stream.

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
    }
});

Events

open

Emitted when the fetch stream is initially opened. This will only be fired once.

value

Emitted when a topic that is selected by the fetch request's topic selector has returned its value. By default, values are provided as Buffer instances. The topic path specifies which topic this value is for.

Parameters:

value: any - the new value of the topic

topicPath: string - the path to the topic to which the value update applies

close

error

Hierarchy

Index

Methods

Methods

close

  • close(): void
  • Close the stream. This will emit a 'close' event to any assigned listeners. No further events will be emitted.

    Returns void

off

  • Remove a listener from a specified event.

    Example:

    // Bind a single listener to the 'foo' event and then deregister it
    var listener = function() {};
    stream.on('foo', listener);
    stream.off('foo', listener);

    Example:

    // Bind a listener to the 'foo' event and deregister all listeners
    var listener = function() {};
    stream.on('foo', listener);
    stream.off('foo');

    Parameters

    • events: string | CallbackMap
    • Optional listener: StreamCallback

      the listener to remove. All listeners for the event are removed if this is not specified. This argument is ignored if the first argument is a CallbackMap.

    Returns Stream

    this stream.

on

  • Register listeners against events.

    A single listener may be bound to an event by passing the event name and listener function.

    Multiple listeners may be bound by passing in a CallbackMap, mapping event names to listener functions.

    Example:

    // Bind a single listener to the 'foo' event
    stream.on('foo', function(arg1, arg2) {
        console.log("Called for 'foo' event", arg1, arg2);
    });

    Example:

    // Bind multiple listeners
    stream.on({
        foo : function() { ... },
        bar : function() { ... },
        baz : function() { ... }
    });

    Parameters

    • events: string | CallbackMap

      the event name or CallbackMap mapping event names to listeners

    • Optional listener: StreamCallback

      the listener to bind to the event, if passed as string. This argument is ignored if the first argument is a CallbackMap.

    Returns Stream

    this stream.