@backand/bkndredux-sdk
Backand SDK for Redux
Last updated 3 years ago by rannn505 .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @backand/bkndredux-sdk 
SYNC missed versions from official npm registry.

bkndredux-sdk

npm version npm downloads

Backand SDK for Redux. This SDK enables you to communicate comfortably and quickly with your Backand app. It wraps the bkndvanilla-sdk to allow easier work on projects involving Redux.

Installation

  • npm:
$ npm i -S @backand/bkndredux-sdk
  • yarn:
$ yarn add @backand/bkndredux-sdk

Quick start

  • Use bkndredux to generate Types,Actions,Reducers for your Backand objects:
$ "./node_modules/.bin/bkndredux" --help
$ "./node_modules/.bin/bkndredux" user obj1 obj2 obj3... -m (thunk/saga)

note: user is a unique object. It has a different Reducer and Types, and it reveals most of the authentication Actions (getUserDetails, signin, signout...).

import { combineReducers } from 'redux'
import user from './user/userReducer'
import obj1 from './obj1/obj1Reducer'
import obj2 from './obj2/obj2Reducer'

combineReducers({
  user,
  obj1,
  obj2
})
  • For the middleware (thunk/saga) you are using, follow the corresponding instructions:

redux-thunk

Download redux-thunk and include it in createStore():

import { createStore, applyMiddleware } from 'redux'
import thunk from 'redux-thunk'

createStore(rootReducer, initialState, applyMiddleware(thunk))

redux-saga

Download redux-saga and include it in createStore():

import { createStore, applyMiddleware } from 'redux'
import createSagaMiddleware from 'redux-saga'
import rootSaga from './sagas.js'

const sagaMiddleware = createSagaMiddleware()
createStore(rootReducer, initialState, applyMiddleware(sagaMiddleware))
sagaMiddleware.run(rootSaga)
  • Import Actions and dispatch them happily! :smile:
import { getUserDetails, signin, useAnonymousAuth, signout } from './user/userActions'

store.dispatch(signin(username, password))
store.dispatch(getUserDetails())

Examples

License

MIT

Current Tags

  • 1.0.30                                ...           latest (3 years ago)

1 Versions

  • 1.0.30                                ...           3 years ago
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 1
Dependencies (5)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |