Git Product home page Git Product logo

react-rxjs-flux's Introduction

react-rxjs-flux

A small library for creating applications based on unidirectional flux like data flow with RxJS. Now with support for RxJS 6.

NPM

Install

yarn add react-rxjs-flux

Usage

// view.tsx
export type ViewProps = {
  number: number,
  inc: () => void,
  dec: () => void
};

const View = (props: ViewProps) => (
    <div>
      {props.number}
      <button onClick={props.inc}>+</button>
      <button onClick={props.dec}>-</button>
    </div>
);

export default View;
// store.ts
import { createStore } from 'react-rxjs';
import { merge, Subject, Observable } from "rxjs";
import { map } from "rxjs/operators";

export const inc$ = new Subject<void>();
export const dec$ = new Subject<void>();

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

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

export default store$;
// container.ts
import { connect } from 'react-rxjs';
import store$, { inc$, dec$ } from './store';
import View, { ViewProps } from './view';

const mapStateToProps = (storeState: number): ViewProps => ({
    number: storeState,
    inc: () => inc$.next(),
    dec: () => dec$.next(),
});

export default connect(store$, mapStateToProps)(View);

License

MIT

react-rxjs-flux's People

Contributors

dependabot[bot] avatar jarlah avatar jarlah-dev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

rituvesh

react-rxjs-flux's Issues

Would you consider allowing the Re-RxJS team to use this package name?

Hi @jarlah !

My name is Josep and I'm the creator of Re-RxJS. Re-RxJS is the result of lots of hours invested into trying to come up with a set of react-rxjs bindings that take full advantage of React latest features (hooks, Suspense and Concurrent Mode). However, we haven't published our first stable release yet.

Re-RxJS takes a different approach than React-RxJS does, because by default our bindings do not put flux-like stores at the forefront. It's still possible to use them, of course, but we don't wan't to have them as first-class citizens of these bindings. Another important difference is the fact that we are able to fully leverage React-Suspense and React Concurrent Mode features like useTransition.

Also, as of today, Re-RxJS is the only set of bindings that -while using state that lives outside of React- are able to work without causing tearing issues on CM.

We have not announced the library yet, but we are planning to do that soon, as soon as we publish our first stable release ๐Ÿ™‚.

The thing is that we are not very happy with the name re-rxjs ๐Ÿ˜ฌ and the name that we really wished we had is react-rxjs. Looking at the npm-stats, I've noticed the low number in the "weekly download" section and I have also noticed that the latest release was 8 months ago. So, I was wondering if you would be so kind to let us publish our first stable version on the react-rxjs package ๐Ÿ™. We would do that using version 3.0.0, and of course: we wouldn't unpublish any of the versions that have been published so far. Also, if version 2 needed further patches or minor updates we would be more than happy to let you handle those, of course. And lastly -regardless of what your answer is to this inquiry- I would love to get feedback from you on Re-RxJS and to have you as a contributor.

Thanks,

Josep

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.