An open API service indexing awesome lists of open source software.

https://github.com/iamcco/rxh

RxJS hook for React with no magic
https://github.com/iamcco/rxh

hook hooks react react-hook react-hooks rxjs

Last synced: 11 months ago
JSON representation

RxJS hook for React with no magic

Awesome Lists containing this project

README

          

# React Hook for RxJS

React ❤️ RxJS

## Install

Using npm

``` sh
npm install rxh
```

Using yarn

``` sh
yarn add rxh
```

## API

``` typescript
type InitialState = State | (() => State);
function useObservable(obs: Observable): State | undefined;
function useObservable(obs: Observable, initialState: InitialState): State;
function useObservable(cb: () => Observable): State | undefined;
function useObservable(cb: () => Observable, initialState: InitialState): State;
```

## Usage

``` typescript
import React from 'react';
import ReactDOM from 'react-dom';
import {timer} from 'rxjs';
import {useObservable} from 'rxh';

const timerObservable = timer(0, 1000)

function CountDown() {
const countDown = useObservable(timerObservable, 0)
return (

{ countDown }

)
}

function App() {
return (




);
}

ReactDOM.render(, document.getElementById('root'));
```