1.0.6 • Published 5 years ago

react-rxjs-hook v1.0.6

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

react-rxjs-hook

NPM JavaScript Style Guide

Install

npm install --save react-rxjs-hook react-rxjs rxjs

Usage

import React from 'react'

import { merge, Subject} from "rxjs";
import { map } from "rxjs/operators";
import { createStore } from 'react-rxjs';
import { useStore } from 'react-rxjs-hook'

const inc$ = new Subject();
const dec$ = new Subject();

const reducer$ = merge(
    inc$.pipe(map(() => (state) => state + 1)),
    dec$.pipe(map(() => (state) => state - 1))
);

const store$ = createStore("test", reducer$, 0);

const Counter = () => {
  const state = useStore(store$);
  return (
    <div>
      {state}
      <button onClick={() => inc$.next()}>+</button>
      <button onClick={() => dec$.next()}>-</button>
    </div>
  )
}

License

MIT © jarlah


This hook is created using create-react-hook.

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago