rva

0.1.3 • Public • Published

rva

Lightweight front-end framework based on redux, redux-saga, redux-rxjs and react-router@2.x.


if you need RxJS in dva, the rva is a good choice, you only need this one in your project, you can write asynchronous code in RxJS.


the source code of rva is added some features on the basis of the source code of dva ,new feature is support for RxJS.


rva is fully compatible with dva, you can replace the use of rva.


rva API is the same as dva API,please read https://github.com/dvajs/dva for some detail


New Features

  • support rxjs: you can use rxjs in rva
  • solve bug: make debugging convenient

Unexpected key warn problem:

https://github.com/dvajs/dva/issues/795

https://github.com/reactjs/react-redux/issues/360

this problem already is solved in rva


Note: make sure you need RxJS in project , because of rva have dependencies

package.json

 "peerDependencies": {
    "react": "15.x",
    "rxjs": "^5.0.0"
  },

so you need

Install


$ npm install rxjs

if you're not currently using RxJS in your project , you still use rva instead of dva, you need to install additional rxjs.

rva includes redux , you don't need to install redux.


simply replace

 
import dva from 'dva';
 
// replace
 
import dva from 'rva';
 

other usage same

rva and dva's api are both the same


Usage

    import React from 'react';
    import Rx from 'rxjs/Rx';
    import dva from 'rva';
 
    const app = dva();
    app.model({
      namespace: 'a',
      state: [],
      reducers: {
         add: (state , action) => state.concat(action),
         sub: (state , action) => state.concat(action)
      },
      epics: {
         epicA : (actions, store) =>
           actions.ofType('a/add').mapTo({ type: 'a/sub' , number :10}),
      }
    });
    app.model({
      namespace: 'b',
      state: [],
      reducers: {
        add: (state, action) => state.concat(action),
        sub: (state, action) => state.concat(action)
      },
      epics: {
        epicB : (actions, store) =>
          actions.ofType('b/add').mapTo({ type: 'b/sub' , number : 20}),
      }
    });
    app.router(() => 1);
    app.start();
 
    app._store.dispatch({ type: 'a/add' });
    app._store.dispatch({ type: 'b/add' });
 
 

redux-saga and rxjs both can run simultaneously

 
import React from 'react';
import Rx from 'rxjs/Rx';     //  you use epics object ,so you need to add this line
import dva from 'rva';
 
const app = dva();
 
app.model({
  namespace: 'c',
  state: [],
  reducers: {
    add: (state, action) => state.concat(action),
    sub: (state, action) => state.concat(action)
  },
  effects: {
    *addDelay({ payload }, { put, call }) {
      yield call(delay, 100);
      yield put({ type: 'add', payload });
    },
  },
  epics: {
    epicC : (actions, store) =>
      actions.ofType('c/sub').mapTo({ type: 'c/add' , payload : 222}),
  }
});
 
app.router(() => 1);
app.start();
 
app._store.dispatch({ type: 'c/addDelay', payload: 333 });
app._store.dispatch({ type: 'c/sub',payload: 111 });
 
 

app.model add epics , epics object is for rxjs


learn more , please read github

UMD

publish a UMD build inside npm package.

License

MIT © hwep

Package Sidebar

Install

npm i rva

Weekly Downloads

0

Version

0.1.3

License

MIT

Last publish

Collaborators

  • hwep