Show:

Stream listens to start, update and end events and emits start, update and end events.

If listening to multiple sources, Stream emits a single event per Engine cycle.

Constructor

Streams.Stream

(
  • [options]
)

Parameters:

  • [options] Object optional

    Options

    • [start] Function optional

      Custom logic to map the start event

    • [update] Function optional

      Custom logic to map the update event

    • [end] Function optional

      Custom logic to map the end event

Example:

 var position = new Transitionable([0,0]);
         var size = new EventEmitter();
        
         var translationStream = Stream.lift(function(position, size){
             var translation = [
                 position[0] + size[0],
                 position[1] + size[1]
             ];
        
             return Transform.translate(translation);
         }, [positionStream, sizeStream]);
        
         translationStream.on('start', function(transform){
             console.log(transform);
         });
        
         translationStream.on('update', function(transform){
             console.log(transform);
         });
        
         translationStream.on('end', function(transform){
             console.log(transform);
         });
        
         position.set([100, 50], {duration : 500});

Item Index

Methods

Methods

filter

(
  • filterFn
)
SimpleStream

Inherited from Streams.SimpleStream:

Filter converts the current stream into a new stream that only emits if the filter condition is satisfied. The filter function should return a Boolean value.

Parameters:

  • filterFn Function

    Function to filter event payload

Returns:

SimpleStream:

stream Filtered stream

lift

(
  • map
  • streams
)
static

Lift is like map, except it maps several event sources, not only one.

Parameters:

Example:

 var liftedStream = Stream.lift(function(payload1, payload2){
                         return payload1 + payload2;
                     }, [stream2, stream2]);
                    
                     liftedStream.on('name'), function(data){
                         // data = 3;
                     });
                    
                     stream2.emit('name', 1);
                     stream2.emit('name', 2);

map

(
  • mapperFn
)
SimpleStream

Inherited from Streams.SimpleStream:

Map converts the current stream into a new stream with a modified (mapped) data payload.

Parameters:

  • mapperFn Function

    Function to map event payload

Returns:

SimpleStream:

stream Mapped stream

merge

(
  • streams
)
static

Batches events for provided object of streams in {key : stream} pairs. Emits one event per Engine cycle.

Parameters:

  • streams Object

    Dictionary of resize streams

pluck

(
  • key
)
SimpleStream

Inherited from Streams.SimpleStream:

Pluck is an opinionated mapper. It projects a Stream onto one of its return values.

Useful if a Stream returns an array or object.

Parameters:

Returns:

SimpleStream:

stream Plucked stream

split

(
  • splitterFn
)

Inherited from Streams.SimpleStream:

Split maps one of several streams based on custom logic. The splitter function should return an EventEmitter type.

Parameters: