0.0.3 • Published 6 years ago

@rxloop/react v0.0.3

Weekly downloads
1
License
ISC
Repository
github
Last release
6 years ago

rxloop-react

installation

npm i @rxloop/react

Usage

import rxLoop from 'rxloop';
import withRxLoop from '@rxloop/react';

const app = rxLoop();
app.model({
  name: 'test',
  state: {
    a: 1,
  },
  reducers: {
    setData(state, action) {
      return {
        ...state,
        a: action.data,
      }
    }
  }
});

app.model({
  name: 'user',
  state: {
    name: 'wxnet',
  },
});

const ReactComponent = ({ streams, dispatch }) => {
  
  streams.user$.subscribe((data) => {});

  streams.test$.subscribe((data) => {});
  
  dispatch({
    type: 'test/setData',
    data: 2,
  });

  return (<div> test </div>);
};


const RxLoopReactComponent = withRxLoop(app, ReactComponent);