rrxjs
v0.1.6
Published
Reactive React Extensions for JavaScript
Downloads
8
Readme
Reactive React Extensions for JavaScript
This library provides a simple wrapper to use RxJS in your React applications. It maps observables to their current values. It manages all necessary subscriptions automatically.
$ npm install rrxjs
If you don't use a package manager you can include this script:
<script crossorigin src="https://unpkg.com/[email protected]/lib/index.umd.js"></script>
<script crossorigin src="https://unpkg.com/[email protected]/lib/index.umd.min.js"></script>
Usage
import React from 'react';
import rrxjs from 'rrxjs';
import { Subject } from 'rxjs/Subject';
// 1. Define your component like any other
let MyComponent = (props) => (
<span>{ props.myObservable }</span>
);
// 2. Wrap it in the rrxjs function
MyComponent = rrxjs(MyComponent);
// 3. Provide an observable as prop from the parent component. Note that the
// dollar sign has been removed from the prop name of the child component
const MyParentComponent = () => (
<div>
<MyComponent myObservable$={new Subject()} />
</div>
);
For more examples check out the unit tests.