Notoriously Punctual Manatee

    react-rxjs-hook
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.6 • Public • Published

    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.

    Keywords

    none

    Install

    npm i react-rxjs-hook

    DownloadsWeekly Downloads

    14

    Version

    1.0.6

    License

    MIT

    Unpacked Size

    116 kB

    Total Files

    23

    Last publish

    Collaborators

    • avatar