# rxact

> an observable application management for Javascript apps

Latest version **1.0.0-beta.0** (published 2017-10-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install rxact
pnpm add rxact
yarn add rxact
bun add rxact
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0-beta.0 |
| Published | 2017-10-24 |
| First published | 2017-09-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 21 |
| Author | Darmody |
| Maintainers | darmody |
| Keywords | observable, stream, state, rxact |

## Links

- npm: https://www.npmjs.com/package/rxact
- Repository: git@github.com:Darmody/rxact
- Issues: https://github.com/Darmody/rxact/issues
- npm.io page: https://npm.io/package/rxact

## Dependencies (1)

- [symbol-observable](https://npm.io/package/symbol-observable.md) ^1.0.4

## 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

- 1.0.0-beta.0 (latest) — 2017-10-24
- 0.11.3 — 2017-10-23
- 0.11.2 — 2017-10-20
- 0.11.1 — 2017-10-20
- 0.11.0 — 2017-10-20
- 0.10.1 — 2017-10-19
- 0.10.0 — 2017-10-19
- 0.9.4 — 2017-10-18
- 0.9.3 — 2017-10-17
- 0.9.2 — 2017-10-17
- 0.9.1 — 2017-10-17
- 0.8.12 — 2017-10-16
- 0.8.11 — 2017-10-16
- 0.8.10 — 2017-10-15
- 0.8.9 — 2017-10-15
- … 18 more at https://npm.io/package/rxact/versions

## README

<h1 align="center">Rxact</h1>

[![npm version](https://img.shields.io/npm/v/rxact.svg?style=flat-square)](https://www.npmjs.com/package/rxact)
[![CircleCI master](https://img.shields.io/circleci/project/github/Darmody/rxact/master.svg?style=flat-square)](https://circleci.com/gh/Darmody/rxact/tree/master)
[![Coveralls master](https://img.shields.io/coveralls/github/Darmody/rxact/master.svg?style=flat-square)](https://coveralls.io/github/Darmody/rxact)

Rxact is an observable application management for Javascript app.

[中文文档](https://github.com/Darmody/rxact/blob/master/CHINESE.md)

## Introduction

Rxact help developer managing application logic and state. Rxact is related to reactive programing, make sure it is what you are familiar with or you want.

## Core Concept

### No Store

It means there is no concept about store in Rxact, but you can still store state. In other state containers like Redux, store is a core concept, because they are forcing on state management. But for mordern Javascript application, state management is not good enough. We need to maintain complex application logic now.

### Stream

Image your application from top to down, for example, from 'user login' to 'button click'. You will see lots of **logic streams**, and they are combined and splited. That is what Rxact thinking, managing your application in **stream** way.

### StateStream

The core component in Rxact is **StateStream**, which is a stream of state. In StateStream you can define operator and event for state, then you can observe the changing of state. And StateStream can even combined together to become a new StateStream. That is the way Rxact manage your application.


## Installation

```
yarn add rxact
```

## Getting Started

#### Step 1, chosing your favorite observable lib.

`Rxact` supports any lib implement [ECMAScript Observable ](https://github.com/tc39/proposal-observable).
including(but not only):
* [RxJS 5](https://github.com/ReactiveX/rxjs)
* [zen-observable](https://github.com/zenparsing/zen-observable)
* [xstream](https://github.com/staltz/xstream) (combining with [rxact-xstream](https://github.com/Darmody/rxact-xstream))
* more...

#### Step 2, setup `Rxact`.

Assume you chosed `RXJS`, then

```javascript
import { StateStream } from 'rxact'
import Rx from 'rxjs'
import { setup } from 'rxact'

setup({ Observable: Rx.Observable })
```

#### Step 3, let's start by writing a counter

```javascript
import { StateStream } from 'rxact'

/**
 * StateStream is a stream for managing state and logic.
 * You shold named the stream and give it initial value.
 * After that, we can emit value and listen to it.
 */
const stream = new StateStream('stream', 0)

/**
 * Emitter is a operator for emitting new value. We define a emitter named "increment" here.
 * Everytime "increment" executed, "stream" will receive new value which equal to previous value plus input value.
*/
stream.emitter('increment', value => prevState => (prevState + value))

/**
 * Subscribing the stream and outputting values.
 * After you subscribed, it will output current value immediately, which means initial value here.
**/
stream.subscribe(value => { console.log(value) })

stream.increment(1)
// output 1.
stream.increment(1)
// output 2.
stream.increment(2)
// output 4.
```

For more infomation, please check documents below.

## Examples

Here are more complex exmaples

* [Counter](https://darmody.github.io/rxact-examples/counter)
* [TodoMVC](https://darmody.github.io/rxact-examples/todomvc)
* [Async](https://darmody.github.io/rxact-examples/async)
* [Real World](https://darmody.github.io/rxact-examples/real-world)

You can checkout the source code on [rxact-examples](https://github.com/darmody/rxact-examples).

## Plugins

You can enhance `Rxact` by adding plugins.
* [Rxact-React](https://github.com/Darmody/rxact-react) `Rxact` binding for `React`.
* [Rxact-Debugger](https://github.com/Darmody/rxact-debugger) debugging and friendly log.
* [Rxact-Rxjs](https://github.com/Darmody/rxact-rxjs) `Rxact` support `Rxjs` natively, but you can get advanced function here.
* [Rxact-Xstream](https://github.com/Darmody/rxact-xstream) Combine `Rxact` and `xstream`.

## Docs

Coming soon ...

## Lisence

[MIT](https://github.com/darmody/rxact/blob/master/LICENSE)

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