stream multiplexer for es6 observables
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.idea/dictionaries
src
test
.gitignore
.npmignore
.travis.yml
README.md
README.template.md
package.json

README.md

muxer

Build Status npm semantic-release

A simple multiplexer utility of RxJS based streams.

Installation

npm install muxer --save

Example

import {Observable as O} from 'rx'
import {mux, demux} from 'muxer'


function create$ () {
  const interval$ = O.interval(1000)
  const mod2$ = interval$.filter(x => x%2 === 0).map(2) 
  const mod3$ = interval$.filter(x => x%3 === 0).map(3)
  const mod7$ = interval$.filter(x => x%7 === 0).map(7)
  mux({mod2$, mod3$, mod7$})
} 
 
// Create a single stream that contains events from each of the individual streams 
const mod$ = create$() 
const [{mod2$}, rest$] = demux(mod$, 'mod2$')

mod2$.subscribe(x => console.log('MOD2', x))
rest$.subscribe(x => console.log('REST', x))

Functions

External

mux(sources) ⇒ Observable

Creates a multiplexed stream from all the input streams

Kind: global function
Returns: Observable - Multiplexed stream

Param Type Description
sources Object Dictionary of source streams.

demux(source$, ...keys) ⇒ Array

De-multiplexes the source stream

Kind: global function
Returns: Array - Tuple of the selected streams and the rest of them

Param Type Description
source$ Observable Input multiplexed stream
...keys String Map of source streams

Observable

An observable is an interface that provides a generalized mechanism for push-based notification, also known as observer design pattern.

Kind: global external
See: RxJS Observable