GithubHelp home page GithubHelp logo

muxer's Introduction

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

muxer's People

Contributors

tusharmath avatar

Stargazers

Kirill Khoroshilov avatar mangocd avatar Rong Shen avatar Savino Basanisi avatar Matti Lankinen avatar

Watchers

 avatar James Cloos avatar  avatar

muxer's Issues

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because we are using your CI build statuses to figure out when to notify you about breaking changes.

Since we did not receive a CI status on the greenkeeper/initial branch, we assume that you still need to configure it.

If you have already set up a CI for this repository, you might need to check your configuration. Make sure it will run on all new branches. If you don’t want it to run on every branch, you can whitelist branches starting with greenkeeper/.

We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

Mux method is not working for me

Hi

I tried to use muxer with angular4:

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$})
} 
const mod$ = this.create$() ;
console.log(mod$);

firstly , ts is not allowing me to use .map(2) , .map(3) , .map(7)
so, I changed them to : -

const mod2$ = interval$.filter(x => x%2 === 0).map(x=>x) 
const mod3$ = interval$.filter(x => x%3 === 0).map(x=>x) 
const mod7$ = interval$.filter(x => x%7 === 0).map(x=>x) 

result I am getting is undefined...
I am not able to understand how the createStream method is working in muxer.
Please help

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.