0.1.1 • Published 5 years ago

react-use-rxjs v0.1.1

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

react-use-rxjs

Hooks for rxjs

Install

npm install --save react-use-rxjs

Usage

import { useRxjs } from 'react-use-rxjs'

const op = input => {
    return input.pipe(map(v => v.toString()))
}
const init = '2'

const RxComponent = () => {
    const [state, publish] = useRxjs(op, init, [])
    return <p onClick={() => publish(3)}>{state}</p>
}

<RxComponent/>

Will render 2 in the beginning, then 3 after clicked.

The first param of useRxjs can also be an Observable, in which case state would be values from the passed Observable and publish would be ignored.

The third param of useRxjs is optional and works just like the last param of official hooks like useMemo or useEffect.

License

MIT

0.1.1

5 years ago

0.1.0

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago