0.3.0 • Published 9 years ago

redux-devshare v0.3.0

Weekly downloads
4
License
MIT
Repository
github
Last release
9 years ago

redux-devshare

NPM version NPM downloads Build Status Dependency Status Code Climate Code Coverage License Code Style

redux-devshare is a redux connector for devshare.

Getting Started

Install through NPM

  1. Install: npm install --save redux-devshare

  2. Include and use redux-devshare when creating redux middleware, when calling an action, or when combining reducers (examples in Documentation section below).

Examples

Simple example coming soon

Documentation

Middleware

import { createStore, applyMiddleware, compose } from 'redux'
import rootReducer from '../reducers' // Combined reducers
import thunk from 'redux-thunk'
import { Middleware } from 'redux-devshare'

const createStoreWithMiddleware = compose(
  // Save for redux middleware
  applyMiddleware(thunk, Middleware)
)(createStore)

Reducers

Add reducers to combineReducers function:

import { combineReducers } from 'redux'
import { routerStateReducer } from 'redux-router'
import { Reducers } from 'redux-devshare'
const { account, projects, entities } = Reducers

let rootReducer = combineReducers({
  account,
  projects,
  entities,
  router: routerStateReducer
})

export default rootReducer

Actions

Example of using Actions from redux-devshare in a smart/linked component (also known as a "container"):

import React, { Component, PropTypes } from 'react'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import { Actions } from 'redux-devshare'

class Main extends Component {
  constructor (props) {
    super(props)
  }
  onLoginClick = e => {
    e.preventDefault()
    const testLogin = { username: 'test', password: 'asdfasdf' }
    this.props.login(testLogin)
  }
  render () {
    return (
      <div className="App">
        <button onClick={ this.onLoginClick }>
          Login
        </button>
      </div>
    )
  }
}

// Place state of redux store into props of component
function mapStateToProps(state) {
  return {
    account: state.account
  }
}

// Place action methods into props
function mapDispatchToProps(dispatch) {
  return bindActionCreators(Actions, dispatch)
}

export default connect(mapStateToProps, mapDispatchToProps)(Main)
0.3.0

9 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.1.6

9 years ago

0.1.5

9 years ago

0.1.4

9 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago