All Projects → reonomy → reactive-hooks

reonomy / reactive-hooks

Licence: MIT License
Reactive Hooks Library

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to reactive-hooks

Rx React Container
Use RxJS in React components, via HOC or Hook
Stars: ✭ 105 (+262.07%)
Mutual labels:  hooks, rxjs
use-metamask
a custom React Hook to manage Metamask in Ethereum ĐApp projects
Stars: ✭ 131 (+351.72%)
Mutual labels:  hooks
preact-urql
Preact bindings for urql
Stars: ✭ 28 (-3.45%)
Mutual labels:  hooks
useAudioPlayer
Custom React hook & context for controlling browser audio
Stars: ✭ 176 (+506.9%)
Mutual labels:  hooks
wagmi
React Hooks for Ethereum
Stars: ✭ 1,691 (+5731.03%)
Mutual labels:  hooks
juliette
Reactive State Management Powered by RxJS
Stars: ✭ 84 (+189.66%)
Mutual labels:  rxjs
git-templates
Templates / Hooks for Your Git Repositories
Stars: ✭ 30 (+3.45%)
Mutual labels:  hooks
tiny-react-with-hooks
⚛︎ Fundamental Implementation of React with Hooks & VDOM
Stars: ✭ 20 (-31.03%)
Mutual labels:  hooks
use-unmount-signal
A React Hook to cancel promises when a component is unmounted
Stars: ✭ 276 (+851.72%)
Mutual labels:  hooks
useStateMachine
The <1 kb state machine hook for React
Stars: ✭ 2,231 (+7593.1%)
Mutual labels:  hooks
polyrhythm
A 3Kb full-stack async effect management toolkit over RxJS. Uses a Pub-Sub paradigm to orchestrate Observables in Node, or the browser (ala Redux Saga). Exports: channel, listen, filter, trigger, after.
Stars: ✭ 23 (-20.69%)
Mutual labels:  rxjs
hooks
A DLL that performs IAT hooking
Stars: ✭ 21 (-27.59%)
Mutual labels:  hooks
rxdeep
rxjs deep state management
Stars: ✭ 47 (+62.07%)
Mutual labels:  rxjs
react-drag
A drag and drop platform based on sortable.js front-end visualization. 一个基于sortable.js的前端可视化搭建的拖拽平台,ui组件采用antd-mobile.通过umi脚手架构建.技术栈采用dva+hooks+umi+antd-mobile+sortable.js+react-color.
Stars: ✭ 51 (+75.86%)
Mutual labels:  hooks
Keyist-Ecommerce
🔑 A simple ecommerce site powered with Spring Boot + Angular 10 + Ngrx + OAuth2
Stars: ✭ 220 (+658.62%)
Mutual labels:  rxjs
CJMethodLog
Objective-C 函数日志监听系统,可监听任意类,任意类的任意方法的调用日志。
Stars: ✭ 26 (-10.34%)
Mutual labels:  hooks
use-debugger-hooks
A small package of custom React hooks that are useful for debugging changes in React hook dependencies across renders
Stars: ✭ 44 (+51.72%)
Mutual labels:  hooks
use-saga-reducer
Use redux-saga without redux
Stars: ✭ 72 (+148.28%)
Mutual labels:  hooks
ngx-model-hacker-news-example
Example repository with Hacker News implementation using Angular, Angular Material & ngx-model
Stars: ✭ 27 (-6.9%)
Mutual labels:  rxjs
reactools
Create React interfaces is easy.
Stars: ✭ 14 (-51.72%)
Mutual labels:  hooks

Reactive Hooks Library For React

GitHub license npm version

$ yarn add @reonomy/reactive-hooks

Reactive Hooks is a library for rendering RxJS Observables using React Hooks.

References

  1. The Road to React: Building the Reactive Hooks Library

  2. Hitchhiker’s guide to Reactive Hooks

  3. Dependency Injection in React

  4. Ajax in the Fog or HTTP in React

API

useRxState

Returns a current value and a function to update it.

[foo, setFoo] = useRxState(foo$);

Example:

import React from 'react';
import { useRxState } from '@reonomy/reactive-hooks';
import { Observable } from 'rxjs';

interface IFoo {
  foo$: Observable<string>;
}

function Foo({ foo$ }: IFoo) {
  const [foo, setFoo] = useRxState(foo$);
  return (
    <button onClick={() => setFoo('bar')}>
        {foo}
    </button>
  );
}

During the initial render, the returned state foo is the same as the current value passed as the first argument foo$. The button click handler will update foo$ and set this state to bar.

useRxStateResult

Returns a current state of a given observable.

foo = useRxStateResult(foo$);

Example:

import React from 'react';
import { useRxState } from '@reonomy/reactive-hooks';
import { Observable } from 'rxjs';

interface IFoo {
  foo$: Observable<string>;
}

function FooReader({ foo$ }: IFoo) {
  const foo = useRxStateResult(foo$);
  return (
    <p>
        {foo}
    </p>
  );
}

useRxEffect

Invokes a callback function when a given observable emits a new state.

useRxEffect(foo$, didUpdate);

Example:

import React from 'react';
import { useRxState } from '@reonomy/reactive-hooks';
import { Observable } from 'rxjs';

interface IFoo {
  foo$: Observable<string>;
}

function FooReader({ foo$ }: IFoo) {
  useRxEffect(foo$, (foo) => {
      console.log('new foo is ', foo);
  });
  return <p>Foo<p>;
}

useRxAjax = useRxState + useRxEffect

Returns an ajax response and a function to submit a request. In addition it invokes a callback function on state updates (e.g. when status is changed from pending to succeeded/failed).

[response, submitRequest] = useRxAjax(ajaxFoo, didUpdate);

The callback function is useful when a side effect should be invoked.

useRxDebounce

Invokes a callback function with a given debounce timeout when a given observable emites a new state.

[response, submitRequest] = useRxDebounce(useRxDebounce, didUpdate, timeout);

useMountEffect

Invokes a callback function when a component is mounted and rendered for the very first time.

useMountEffect(didMount);

Author

Dmitry Doronin

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].