# tsdux-observable

> TSdux utilities for Observables

Latest version **4.0.1** (published 2020-03-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install tsdux-observable
pnpm add tsdux-observable
yarn add tsdux-observable
bun add tsdux-observable
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.0.1 |
| Published | 2020-03-20 |
| First published | 2018-03-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 9.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Junyoung Clare Jang |
| Maintainers | ailrun |
| Keywords | redux, tsdux, redux-observable, rxjs, reactive, observable, typescript, type-safe, state |

## Links

- npm: https://www.npmjs.com/package/tsdux-observable
- Repository: https://github.com/Ailrun/tsdux-observable
- Homepage: https://github.com/Ailrun/tsdux-observable#readme
- Issues: https://github.com/Ailrun/tsdux-observable/issues
- npm.io page: https://npm.io/package/tsdux-observable

## Alternatives

- [@reckona/mreact-store](https://npm.io/package/@reckona/mreact-store.md) — 976 weekly downloads
- [regular-state](https://npm.io/package/regular-state.md) — 410 weekly downloads
- [@pacote/flux-actions](https://npm.io/package/@pacote/flux-actions.md) — 65 weekly downloads
- [@pilotlab/lux-debug](https://npm.io/package/@pilotlab/lux-debug.md) — 39 weekly downloads
- [vue-persist-state](https://npm.io/package/vue-persist-state.md) — 19 weekly downloads

## Recent versions

- 4.0.1 (latest) — 2020-03-20
- 4.0.0 — 2018-12-08
- 3.0.0 — 2018-05-28
- 2.2.2 — 2018-05-06
- 2.2.1 — 2018-05-06
- 2.1.1 — 2018-03-08
- 2.1.0 — 2018-03-08

## README

# tsdux-observable #

[![npm latest version](https://img.shields.io/npm/v/tsdux-observable/latest.svg)](https://www.npmjs.com/package/tsdux-observable)
[![npm total download](https://img.shields.io/npm/dt/tsdux-observable.svg)](https://www.npmjs.com/package/tsdux-observable)
[![github license](https://img.shields.io/github/license/Ailrun/tsdux-observable.svg)](https://github.com/Ailrun/tsdux-observable/blob/master/LICENSE)
[![github latest tag](https://img.shields.io/github/tag/Ailrun/tsdux-observable.svg)](https://github.com/Ailrun/tsdux-observable/tags)
[![github commit from latest](https://img.shields.io/github/commits-since/Ailrun/tsdux-observable/latest.svg)](https://github.com/Ailrun/tsdux-observable)
[![travis status](https://travis-ci.org/Ailrun/tsdux-observable.svg?branch=master)](https://travis-ci.org/Ailrun/tsdux-observable)
[![codecov coverage](https://img.shields.io/codecov/c/github/ailrun/tsdux-observable.svg)](https://codecov.io/gh/Ailrun/tsdux-observable)

[TSdux](https://github.com/Ailrun/tsdux) utilities for Observables.

The latest version supports RxJS version 6 only. If you want to use this package with RxJS version 5, see [support-v5](https://github.com/Ailrun/tsdux-observable/tree/support-v5) branch (tsdux-observable@^2).

## Table of Contents ##

- [How To Install](#how-to-install)
- [API](#api)
- [Author](#author)

## How To Install ##

```
npm install --save redux rxjs tsdux tsdux-observable
```

## API ##

- [ofType](#ofType)
- [toPayload](#topayload)

### ofType ###

``` typescript
function ofType<AC extends ActionCreator<string, any>>(
  actionCreators: AC | Array<AC>,
): (source: Observable<AnyAction>) => Observable<AC['action']>
```

Function for filtering actions with `ActionCreator`s of [tsdux](https://github.com/Ailrun/tsdux).  
This function filter out all actions except specified actions by `ActionCreator`s.

``` typescript
const AddTest = action('app/test/ADD_TEST', props<{ id: number test: string }>());
const RemoveTest = action('app/test/REMOVE_TEST', props<{ id: number }>());

Observable([
  AddTest.create({ id: 0, test: '123' }),
  RemoveTest.create({ id: 0 }),
  AddTest.create({ id: 1, test: 'ABabABC' }),
])
  .let(ofType(AddTest))
  .subscribe((action) => {
    console.log(action);
    // first logs { type: 'app/test/ADD_TEST', id: 0, test: '123' }
    // and then logs { type: 'app/test/ADD_TEST', id: 1, test: 'ABabABC' }
  });
```

### toPayload ###

```typescript
function toPayload<PA extends PayloadAction<string, any>>(): (source: Observable<PA>) => Observable<PA['payload']>
```

Function for mapping Observable of `PayloadAction` to Observable of `payload` property.

``` typescript
Observable([
  action('abc', payload<string>()).create('d012d@!gWE'),
  action('ttt', payload<number>()).create(178),
])
  .let(toPayload())
  .toArray()
  .subscribe((result) => {
    console.log(result) // ['d012d@!gWE', 178]
  });
```

## Author ##

Junyoung Clare Jang [@Ailrun]

[@Ailrun]: https://github.com/Ailrun

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