Show:
Extends Core.EventHandler

A SimpleStream wraps an EventHandler and provides convenience methods of map, filter, split, and pluck to transform one stream into another.

Constructor

Streams.SimpleStream

() private

Example:

Item Index

Methods

Methods

filter

(
  • filterFn
)

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

Parameters:

  • filterFn Function

    Function to filter event payload

lift

(
  • map
  • streams
)
static

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

Parameters:

Example:

 var liftedStream = SimpleStream.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
)

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

Parameters:

  • mapperFn Function

    Function to map event payload

pluck

(
  • key
)

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

Useful if a Stream returns an array or an object.

Parameters:

split

(
  • splitterFn
)

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

Parameters: