Home Manual Reference Source Repository
import Funnel from 'protonic/src/funnel.js'
public class | source

Funnel

Extends:

Stream → Funnel

A Funnel is a special type of Stream that combines the states from feeder streams.

Constructor Summary

Public Constructor
public

constructor(sourceMap: Immutable.Map): Funnel

A Funnel is a special type of Stream that combines the states from feeder streams.

Method Summary

Public Methods
public

destroy - cleans up a Funnel's feeder subscribers.

public

forceState(state: Immutable)

forceState - Funnels can accept new state an send state back up the subscription chain.

public

subscribe(observer: function): object

subscribe - Overwrites base Stream class's subscribe method. Funnels should not emit state to subscribers until all source streams have defined state.

Inherited Summary

From class Stream
public get

state: Immutable: *

get state - a getter for returning the current internal state of the Stream.

public set

state(newState: type): type: *

set state - a setter that's probably more clever than it needs to be. Instead of setting the internal state, it calls next.

stream.next(newState)
// is functionally the same as
stream.state = newState

Like I said, maybe too clever, but I thinks allow for a more delarative style when writing transformers.

public

forceState(state: Immutable.Map)

forceState - called when hydrating state from another source.

public

logStack(name: string, stack: Stack)

logStack - Adds a stack to automatically add state changes.

public

next(newState: Immutable)

next - Receives new state (externally, ideally through a transformer) and verifies that the new state is different from the Stream's current state before passing on to sendState (and, all the observers, by extension).

public

subscribe(observer: function): object

subscribe - takes a callback function that is executed any time the stream received new state.

Public Constructors

public constructor(sourceMap: Immutable.Map): Funnel source

A Funnel is a special type of Stream that combines the states from feeder streams. Once all of the feeder streams have sent state, the Funnel will send the combined state to any observers. When creating the Funnel, the sourceMap describes the shape of the combined state. The key for each stream will be the key used to access the state of that stream on the combined state object.

Override:

Stream#constructor

Params:

NameTypeAttributeDescription
sourceMap Immutable.Map

a Map of the feeder streams.

Return:

Funnel

returns an instance of the Funnel stream.

Public Methods

public destroy() source

destroy - cleans up a Funnel's feeder subscribers.

public forceState(state: Immutable) source

forceState - Funnels can accept new state an send state back up the subscription chain. This should only be used in cases of restoring state.

Override:

Stream#forceState

Params:

NameTypeAttributeDescription
state Immutable

The new state to hydrate the funnel.

public subscribe(observer: function): object source

subscribe - Overwrites base Stream class's subscribe method. Funnels should not emit state to subscribers until all source streams have defined state.

Override:

Stream#subscribe

Params:

NameTypeAttributeDescription
observer function

the obeserver function to listen to state changes.

Return:

object

a subscriber object