Skip to content
プロジェクト

概要

Reactive React application flow with React, RxJS and Redux

Web・アプリ開発

この数値の測り方

計測したスター増加

24時間
0
7日間
0
15日間
0
1か月
履歴を収集中

期間ごとの純増数です。期間は重複しており、日別の値ではありません。未計測の値は空欄です。スター数は注目度の指標であり、品質の保証ではありません。

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)

関連プロジェクトを探す

読み込み中…