# async-iterator-from-rx

> A tool to convert RxJS style observable stream asyncGenerator

Latest version **1.0.0** (published 2022-01-28) · ISC license · 0 weekly downloads

## Install

```sh
npm install async-iterator-from-rx
pnpm add async-iterator-from-rx
yarn add async-iterator-from-rx
bun add async-iterator-from-rx
```

## Health

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

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

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2022-01-28 |
| First published | 2022-01-28 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 12.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | majunchen |
| Maintainers | lpegasus |
| Keywords | async iterator, stream, rxjs |

## Links

- npm: https://www.npmjs.com/package/async-iterator-from-rx
- Repository: https://github.com/LPegasus/async-iterator-from-rx
- Homepage: https://github.com/LPegasus/async-iterator-from-rx#readme
- Issues: https://github.com/LPegasus/async-iterator-from-rx/issues
- npm.io page: https://npm.io/package/async-iterator-from-rx

## Alternatives

- [byte-size](https://npm.io/package/byte-size.md) — 2.1M weekly downloads
- [speed-limiter](https://npm.io/package/speed-limiter.md) — 16.0K weekly downloads
- [@powersync/node](https://npm.io/package/@powersync/node.md) — 10.9K weekly downloads
- [@ledgerhq/coin-cardano](https://npm.io/package/@ledgerhq/coin-cardano.md) — 1.0K weekly downloads
- [@jayesol/jayeson.lib.streamfinder](https://npm.io/package/@jayesol/jayeson.lib.streamfinder.md) — 1.0K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2022-01-28

## README

# async-iterator-from-rx

A tool to convert RxJS style observable stream asyncGenerator.

## Motivation

RxJS is not so common compare with async/await and it's hard to learn. This tool can help user who is not so familiar with observable to use observables in async/await way.

[![npm version](https://badge.fury.io/js/async-iterator-from-rx.svg)](https://www.npmjs.com/package/async-iterator-from-rx)[![build](https://travis-ci.org/LPegasus/async-iterator-from-rx.svg?branch=master)](https://travis-ci.org/LPegasus/async-iterator-from-rx)[![coverage](https://img.shields.io/codecov/c/github/LPegasus/async-iterator-from-rx.svg?style=flat-square)](https://codecov.io/gh/LPegasus/async-iterator-from-rx)[![install size](https://packagephobia.now.sh/badge?p=async-iterator-from-rx)](https://packagephobia.now.sh/result?p=async-iterator-from-rx)[![MINIFIED](https://badgen.net/bundlephobia/min/async-iterator-from-rx)](https://bundlephobia.com/result?p=async-iterator-from-rx)[![MINIFIED + GZIPPED](https://badgen.net/bundlephobia/minzip/async-iterator-from-rx)](https://badgen.net/bundlephobia/min/async-iterator-from-rx)

## Install

`npm i -S rx-from-async-iterator tslib rxjs`

## Example

### Simple usage

For example, we need to collect 10 user touch points when in some case. And we've already have a click stream. Use `asyncIteratorFromRx` to convert stream to asyncIterator so that you can use `for await ... of` syntax to process the stream signal.

```typescript
import { asyncIteratorFromRx } from "async-iterator-from-rx";
import { fromEvent } from "rxjs";

const click$ = fromEvent("pointerdown", document.body); // A click stream.

async function batchCollectByCount(count: number) {
  const clickTrace: Array<[x: number, y: number]> = [];
  const clickIterator = asyncIteratorFromRx(click$); // Convert click stream to an asyncIterator
  for await (const evt of clickIterator) {
    // use `for await ... of` to scan the click stream
    clickTrace.push([evt.x, evt.y]);
    if (clickTrace.length === count) {
      break;
    }
  }
  return clickTrace;
}

batchCollectByCount(10).then(uploadClickTrace);
```

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