# @reactive-js/observable

> Reactive-Js's core reactive programming API.

Latest version **0.0.37** (published 2020-04-21) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @reactive-js/observable
pnpm add @reactive-js/observable
yarn add @reactive-js/observable
bun add @reactive-js/observable
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.0.37 |
| Published | 2020-04-21 |
| First published | 2019-12-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 5 |
| Unpacked size | 405.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 11 |
| Author | David Bordoley |
| Maintainers | bordoley |
| Keywords | asynchronous, data flow, data-flow, frp, functional programming, functional-reactive-programming, ix, observable, observables, react, reactjs, reactive, reactive-extensions, reactive-js, reactive-x, rx, rxjs, scheduler, state management, state-management, stream, streams |

## Links

- npm: https://www.npmjs.com/package/@reactive-js/observable
- Repository: https://github.com/bordoley/reactive-js
- Homepage: https://github.com/bordoley/reactive-js#readme
- Issues: https://github.com/bordoley/reactive-js/issues
- npm.io page: https://npm.io/package/@reactive-js/observable

## Dependencies (5)

- [@reactive-js/pipe](https://npm.io/package/@reactive-js/pipe.md) ^0.0.37
- [@reactive-js/option](https://npm.io/package/@reactive-js/option.md) ^0.0.37
- [@reactive-js/scheduler](https://npm.io/package/@reactive-js/scheduler.md) ^0.0.37
- [@reactive-js/disposable](https://npm.io/package/@reactive-js/disposable.md) ^0.0.37
- [@reactive-js/enumerable](https://npm.io/package/@reactive-js/enumerable.md) ^0.0.37

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.0.37 (latest) — 2020-04-21
- 0.0.36 — 2020-04-21
- 0.0.35 — 2020-04-20
- 0.0.34 — 2020-04-19
- 0.0.33 — 2020-04-10
- 0.0.32 — 2020-04-03
- 0.0.31 — 2020-03-23
- 0.0.30 — 2020-03-16
- 0.0.29 — 2020-03-11
- 0.0.18 — 2019-12-25
- 0.0.17 — 2019-12-24
- 0.0.16 — 2019-12-23
- 0.0.15 — 2019-12-21
- 0.0.14 — 2019-12-18
- 0.0.13 — 2019-12-15
- … 12 more at https://npm.io/package/@reactive-js/observable/versions

## README

# @reactive-js/observable

Reactive-Js's core reactive programming API.

Reactive-Js unifies reactive and interactive programming into a single API, defined by two core interfaces: [ObservableLike](./docs/interfaces/observablelike.md) and [EnumerableLike](./docs/interfaces/enumerablelike.md). In addition, basic utilities for safely creating, transforming, and using `ObservableLike` and `EnumerableLike` streams are provided.

`ObservableLike` streams are always asynchronous. Subscribing only sets up subscription, but does not synchronously produce values (doing so is a programming error). Instead scheduling is deeply integrated into the `SubscriberLike` type. During subscription setup, `ObservableLike` sources schedule work to be done in the future, such as iterating through an iterable source. This enables tight integrationg with platform specific scheduling implementations such as React's internal scheduler.

### A note on backpressure

While reactive-js does not provide an API to directly apply backpressure to an `ObservableLike` source, the library does provided several primitives that can be used to achieve the effect.

CPU bound backpressure can be achieved via the [@reactive-js/scheduler](../scheduler) [`SchedulerLike`](../scheduler/docs/interfaces/schedulerlike.md) interface's support for cooperative multi-tasking. Specifically, `ObservableLike` sources must honor a `SchedulerLike`'s `shouldYield` requests, yielding control back to the scheduler, and returning a `SchedulerContinuationLike` if additional work is to be completed.

A second approach is provided by the [@reactive-js/async-enumerable](../async-enumerable) package, which defines a push/pull interface for iterating through asynchronous producers.

## Installation

### via npm

```sh
npm install @reactive-js/observable
```

### via yarn

```sh
yarn add @reactive-js/observable
```

## Usage

```typescript
import { subscribe } from "@reactive-js/observable";
import { pipe } from "@reactive-js/pipe";

const observableSource;
const platformScheduler;

// Setup a subscription to the observableSource using the platform scheduler
const subscription = pipe(observableSource, subscribe(platformScheduler));

// ...later in the future

// Dispose the observable subscription
subscription.dispose();
```

## Documentation

API documentation is available [here](./docs).

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