Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
joshiefishbein and hhff Support v2 Enpoints (#247)
* Support v2 Enpoints

* update brandibble.js hash

* bump package version up a minor
Latest commit b084f6b Apr 23, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci
src
tests
.babelrc
.editorconfig
.env.example add .env for configuration Jul 24, 2018
.eslintrc
.gitignore set up rollup for building Aug 2, 2018
.npmignore set up rollup for building Aug 2, 2018
README.md add .env for configuration Jul 24, 2018
karma.conf.js 232 ensure invalid requested at is set one location change (#233) Mar 5, 2019
package.json
rollup.config.js reference package dependencies directly Aug 13, 2018
webpack.config.base.js remove redux-crud Jul 30, 2018
webpack.config.development.js
webpack.config.production.js configuration for public release (#47) Mar 6, 2017

README.md

Brandibble Redux

npm CircleCI Status Open Source Love

A set of actions, reducers, and redux middleware for Brandibble.

Configuration

Middleware

import { brandibbleMiddleware } from 'brandibble-redux';
import { createStore, applyMiddleware, compose } from 'redux';

const store = createStore(
  ...
  compose(
    applyMiddleware(...brandibbleMiddleware),
  )
  ...
);

Actions

import { fetchAllergens } from 'brandibble-redux';

...
dispatch(fetchAllergens(brandibble));
...

Reducers

import { reducer as brandibbleReducer } from 'brandibble-redux';
import { combineReducers } from 'redux';

export default combineReducers({
  ...
  brandibble: brandibbleReducer,
  ...
});

Example

import App from './components/App';
import LoadingState from './components/LoadingState';
import {
  Brandibble,
  setupBrandibbleRedux,
} from 'brandibble-redux';
import { connect } from 'redux';
import { Component } from 'react'; // or 'react-native'

const brandibble = new Brandibble({
  // ...config
});

const mapStateToProps = state => {
  const { setupBrandibbleRedux } = state.brandibble.status;

  return {
    loaded: setupBrandibbleRedux === 'FULFILLED',
  };
};

const mapDispatchToProps = dispatch => {
  setup: () => dispatch(setupBrandibbleRedux(brandibble)),
};

@connect(mapStateToProps, mapDispatchToProps)
export default class Main extends Component {

  componentWillMount() {
    setup();
  }

  render() {
    const { loaded } = this.props;
    return loaded ? <LoadingState /> : <App />;
  }
}

Working on Brandibble Redux

IMPORTANT: Set an environment variable called BRANDIBBLE_API_KEY by making a file named .env in the root of this directory and filling it out with your Brandibble API key before running tests (see .env.example for an example).

git clone https://github.com/sanctuarycomputer/brandibble-redux
cd brandibble-redux
npm install

// Run tests (in chrome) with:
npm test
You can’t perform that action at this time.