redux-fireuser

    0.0.1 • Public • Published

    redux-fireuser

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

    Redux middleware, actions, and reducers for Fireuser

    Getting Started

    Install through NPM

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

    Documentation

    Middleware

    import { createStore, applyMiddleware, compose } from 'redux';
    import rootReducer from '../reducers'; // Combined reducers
    import thunkMiddleware from 'redux-thunk';
    import { createMiddleware } from 'redux-fireuser';
     
    let fireuserMiddleware = createMiddleware('testApp');
    const createStoreWithMiddleware = compose(
      // Save for redux middleware
      applyMiddleware(thunkMiddleware, fireuserMiddleware)
    )(createStore);

    Reducers

    import { combineReducers } from 'redux';
    import { routerStateReducer } from 'redux-router';
    import { Reducers } from 'redux-fireuser';
    const rootReducer = combineReducers({
      account: Reducers.account,
      entities: Reducers.entities,
      router: routerStateReducer
    });
     
    export default rootReducer;

    Actions

    import React, { Component, PropTypes } from 'react';
    import { bindActionCreators } from 'redux';
    import { connect } from 'react-redux';
    import { Actions } from 'redux-fireuser';
     
    class Main extends Component {
      constructor(props) {
        super(props);
      }
      onLoginClick = (e) => {
        e.preventDefault()
        this.props.login({username: 'test', password: 'asdfasdf'})
      };
      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);

    Install

    npm i redux-fireuser

    DownloadsWeekly Downloads

    2

    Version

    0.0.1

    License

    MIT

    Last publish

    Collaborators

    • prescottprue