Ember.streams.Ember.stream.chain()

chain (value, fn) Object|Streamprivate

Defined in packages/ember-htmlbars/lib/streams/utils.js:271

Generate a new stream by providing a source stream and a function that can be used to transform the stream's value. In the case of a non-stream object, returns the result of the function.

The value to transform would typically be available to the function you pass to chain() via scope. For example:

    let source = ...;  // stream returning a number
                           // or a numeric (non-stream) object
    let result = chain(source, function() {
      let currentValue = read(source);
      return currentValue + 1;
    });

In the example, result is a stream if source is a stream, or a number of source was numeric.

Parameters:

value Object|Stream
A stream or non-stream object.
fn Function
Function to be run when the stream value changes, or to be run once in the case of a non-stream object.

Returns:

Object|Stream
In the case of a stream `value` parameter, a new stream that will be updated with the return value of the provided function `fn`. In the case of a non-stream object, the return value of the provided function `fn`.
doc_EmberJs
2016-11-30 16:51:45
Comments
Leave a Comment

Please login to continue.