🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

callbag-subscribe

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

callbag-subscribe

A callbag sink (listener) that connects an Observer a-la RxJS.

1.5.1
latest
Source
npm
Version published
Weekly downloads
6.6K
69.29%
Maintainers
1
Weekly downloads
 
Created
Source

callbag-subscribe 👜

CircleCI npm npm

A callbag sink (listener) that connects an Observer a-la RxJS.

npm install callbag-subscribe

Usage:

Simple (next only)

import pipe from 'callbag-pipe';
import interval from 'callbag-interval';
import subscribe from 'callbag-subscribe';

const source = interval( 10 );

pipe(
  source,
  subscribe( val => console.log( val ) )
);

// 0
// 1
// 2
// 3
// 4
// 5
// 6
// 7
// 8
// 9

Complete observer

import pipe from 'callbag-pipe';
import interval from 'callbag-interval';
import subscribe from 'callbag-subscribe';

const source = interval( 10 );

pipe(
  source,
  subscribe({
    next: val => console.log( val ),
    complete: () => console.log( 'Done!' ),
    error: err => console.error( err )
  })
);

// 0
// 1
// 2
// 3
// 4
// 5
// 6
// 7
// 8
// 9
// Done!

Disposal

Use the returned disposal function to terminate the subscription.

const source = fromEvent( document.body, 'click' );

const dispose = pipe(
  source,
  subscribe({
    next: ev => console.log( 'Click:', ev )
  })
);

// Do some stuff...

dispose(); // Terminate the subscription.

Keywords

callbag

FAQs

Package last updated on 12 Feb 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts