• Stars
    star
    257
  • Rank 158,728 (Top 4 %)
  • Language
  • Created about 9 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Reactive React application flow with React, RxJS and Redux

thisless React

Reactive React application flow, with React, RxJS and Redux.

It is all about...

  • thisless: this cannot be found in examples!

  • Fully Reactive: With RxJS and React Reactive Class, components are made reactive and observable.

  • It's just React: No magic! Use the technique you already know, without learning new library or API and plays well with your existing React apps.

  • Pure View: Completely decouple View from Model, no more Model injection. Code like store.dispatch(action) or store.getState() cannot be found in View.

  • High Performance: Introduce Static Component and Data Binding by default. React will no longer diff entire huge Virtual DOM. See Vjeux's slide Animated β€” React Performance Toolbox for more details.

Getting started

The building blocks are functions that returning element node and event streams.

function button(props) {
  const clickEv$ = new Rx.Subject();
  const element = (
    <button onClick={clickEv$.onNext.bind(clickEv$)}>
      {props.text}
    </button>
  );

  return {
    element,
    events: {
      clickEv$
    }
  }
}

Compose these functions and eventually you will get a function with root element node and event streams of the app.

const store = configureStore();
const { state$ } = store;

const {
  element: App,
  events
} = app(state$);

ReactDOM.render(App, mountNode);

And then write code to handle these event streams, like dealing with store or interacting with the browser.

function handleEvent(store, events) {
  events.clickIncreaseButton$.subscribe(() => {
    store.dispatch(/* ... */);
  });
}

handleEvent(store, events);

That's it!

See examples for complete app code.

Tip about Redux middleware

There is no restrictions on how to use Redux in your thisless React app, but I highly recommend using RxJS streams to replace middleware, they handles async operations well and in this way your application flow will become more clear and straightforward (and you write less code!).

Feedbacks are welcome!

Feel free to discuss via opening issues or send pull requests!

Inspirations

Cycle.js: I borrowed lots of concepts from it.

Angular: Don't create components all the time, element + function is good enough to get the job done.

License

The MIT License (MIT)

More Repositories

1

rx-redux

A reimplementation of redux using RxJS.
JavaScript
421
star
2

atom-live-server

Launch a simple development http server with live reload capability.
JavaScript
121
star
3

react-reactive-class

Reactive React components
JavaScript
44
star
4

redux-core

Minimal redux
JavaScript
42
star
5

karma-sourcemap-writer

Sourcemap writer for karma.
JavaScript
24
star
6

elm-architecture

The Elm Architecture in JavaScript
JavaScript
16
star
7

react-dnd-card

Create a drag and drop list in a minute. Built on top of React DnD.
JavaScript
12
star
8

react-starter-kit

React Starter Kit
JavaScript
7
star
9

json-parse

Adds syntax highlighting for JSON.parse(tagged template strings).
4
star
10

react-render-loader

A webpack loader that renders React components to HTML strings.
JavaScript
4
star
11

router5-link-interceptor

Link interceptor for router5.
JavaScript
4
star
12

unbloat

Atomic CSS in JS
JavaScript
4
star
13

simple-universal-web-app

Dead simple, no router and other stuff. Only to show how universal web apps work.
JavaScript
4
star
14

evstore

Event based state management library
JavaScript
3
star
15

clex

Switch-case free state management library
JavaScript
3
star
16

undo-redo-demo

undo redo 倧作戰
HTML
2
star
17

srender

Tiny web framework
JavaScript
2
star
18

default-css-class-loader

BEM style like CSS naming conventions with CSS Modules made easy.
JavaScript
1
star
19

jas-chen.github.io

HTML
1
star
20

css-in-js

CSS in JS techniques - Version and Downloads.
1
star
21

tomcat6-jre7-ssl-admin

Tomcat 6 with SSL and Admin user configuration
Shell
1
star
22

vueactive

React bindings for @vue/reactivity
JavaScript
1
star
23

rescript-create-react-app

Create React App with ReScript
HTML
1
star
24

jsty

Fast and tiny CSS in JS library
TypeScript
1
star