# callbag-subject

> A callbag listener sink which is also a listenable source

Latest version **2.1.0** (published 2020-11-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install callbag-subject
pnpm add callbag-subject
yarn add callbag-subject
bun add callbag-subject
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.0 |
| Published | 2020-11-20 |
| First published | 2018-02-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 6.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 27 |
| Author | staltz.com |
| Maintainers | staltz |
| Keywords | callbag |

## Links

- npm: https://www.npmjs.com/package/callbag-subject
- Repository: https://github.com/staltz/callbag-subject
- Homepage: https://github.com/staltz/callbag-subject#readme
- Issues: https://github.com/staltz/callbag-subject/issues
- npm.io page: https://npm.io/package/callbag-subject

## Dependencies (1)

- [callbag](https://npm.io/package/callbag.md) ^1.3.0

## Recent versions

- 2.1.0 (latest) — 2020-11-20
- 2.0.0 — 2020-10-19
- 1.0.2 — 2018-03-01
- 1.0.1 — 2018-02-07
- 1.0.0 — 2018-02-01

## README

# callbag-subject

A callbag listener sink which is also a listenable source, and maintains an internal list of listeners. Use this like you would use RxJS Subject.

`npm install callbag-subject`

## example

First call `makeSubject` to create a `subject` which is then a normal callbag, so:

- Call it with args `(1, data)` to send data into the subject
- Call it with args `(2, err)` to send an error into the subject
- Call it with args `(2)` to make the subject complete

```js
const observe = require('callbag-observe');
const makeSubject = require('callbag-subject');

const subject = makeSubject();

setInterval(() => { subject(1, 'a'); }, 1000);

// First observer is added immediately
observe(x => console.log(x + 1))(subject);

// First observer is added after 2.5 seconds
setTimeout(() => {
  observe(x => console.log(x + 2))(subject);
}, 2500);

// a1
// a1
// a1
// a2
// a1
// a2
// ...
```

---
_Source: https://npm.io/package/callbag-subject · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
