zebulonj / callbag-behavior-subject

A callbag subject (source, sink) that repeats its last value on connection.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

callbag-behavior-subject

A callbag subject (listener, sink) that repeats its last value on connection.

npm install callbag-behavior-subject

Usage:

import makeBehaviorSubject from 'callbag-behavior-subject';
import subscribe from 'callbag-subscribe';
import pipe from 'callbag-pipe';

const subject = makeBehaviorSubject( 'A' );

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

const dispose = pipe(
  subject,
  subscribe( observer )
);

subject( 1, 'B' );
subject( 2 );

// A
// B
// Done!

About

A callbag subject (source, sink) that repeats its last value on connection.

License:MIT License


Languages

Language:JavaScript 100.0%