@21epub/use-rxjs-subject
TypeScript icon, indicating that this package has built-in type declarations

0.1.4 • Public • Published

@21epub/use-rxjs-subject

Rxjs Subject with React Hooks

NPM JavaScript Style Guide Build Status Codecov

Install

npm install --save @21epub/use-rxjs-subject

Usage

import React, { Component } from 'react'

import useRxjsSubject from '@21epub/use-rxjs-subject'

const Subject$ = new BehaviorSubject(0)

const TestFn1: React.FC = () => {
  const [state] = useRxjsSubject(Subject$)
  return <div>{state}</div>
}

const TestFn2: React.FC = () => {
  const [state] = useRxjsSubject(Subject$)
  return <div>{state}</div>
}

const App: React.FC = () => {
  return (
    <>
      <TestFn1 />
      <TestFn2 />
    </>
  )
}

For Details: See Example

Building and running on localhost

First install dependencies and then install peerDeps for parcel dev:

npm install
npm run install-peers

To run Example in hot module reloading mode:

npm start

To create a production build:

npm run build-prod

To create a bundle module build:

npm run build

Running

Open the file dist/index.html in your browser

Testing

To run unit tests:

npm test

License

MIT © garry

Readme

Keywords

none

Package Sidebar

Install

npm i @21epub/use-rxjs-subject

Weekly Downloads

1

Version

0.1.4

License

MIT

Unpacked Size

11 kB

Total Files

10

Last publish

Collaborators

  • csj117
  • gary.guzy
  • zhangwei0126
  • dxsix
  • wagon1104
  • ongyuxing