checkStore.js 471 Bytes
Newer Older
Julien Benchetrit's avatar
Julien Benchetrit committed
1
import invariant from 'invariant';
dengxiaofeng's avatar
dengxiaofeng committed
2
import { conformsTo, isFunction, isObject } from 'lodash';
Julien Benchetrit's avatar
Julien Benchetrit committed
3 4 5 6 7 8 9 10 11 12 13 14 15

export default function checkStore(store) {
  const shape = {
    dispatch: isFunction,
    subscribe: isFunction,
    getState: isFunction,
    replaceReducer: isFunction,
    runSaga: isFunction,
    injectedReducers: isObject,
    injectedSagas: isObject,
  };
  invariant(
    conformsTo(store, shape),
dengxiaofeng's avatar
dengxiaofeng committed
16
    '(src/utils...) injectors: Expected a valid redux store',
Julien Benchetrit's avatar
Julien Benchetrit committed
17 18
  );
}