Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/zebulonj/callbag-behavior-subject

A callbag subject (source, sink) that repeats its last value on connection.
https://github.com/zebulonj/callbag-behavior-subject

callbag observables pub-sub reactive rx

Last synced: 3 months ago
JSON representation

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

Awesome Lists containing this project

README

        

# callbag-behavior-subject

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

`npm install callbag-behavior-subject`

## Usage:

```js
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!
```