Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/* global */
import { init } from '@rematch/core';
import createPersistPlugin, { getPersistor } from '@rematch/persist';
import createLoadingPlugin from '@rematch/loading';
import storage from 'redux-persist/es/storage';
import * as models from '../models';
// Create plugins
const persistPlugin = createPersistPlugin({
version: 2,
storage,
blacklist: [],
});
const loadingPlugin = createLoadingPlugin({});
const configureStore = () => {
const store = init({
models,
redux: {
middlewares: [],
},
plugins: [persistPlugin, loadingPlugin],
});
const persistor = getPersistor();
const { dispatch } = store;
return { persistor, store, dispatch };
};
import * as models from './models'
import { init } from '@rematch/core'
import immerPlugin from '@rematch/immer'
import createLoadingPlugin from '@rematch/loading'
const immer = immerPlugin()
// see options API below
const options = {}
const loading = createLoadingPlugin(options)
const store = init({ models, plugins: [immer, loading] })
export default store
import React from 'react'
import ReactDOM from 'react-dom'
import { Provider } from 'react-redux'
import { init } from '@rematch/core'
import createLoadingPlugin from '@rematch/loading'
import App from './App'
import example from './example'
const loadingPlugin = createLoadingPlugin({ asNumber: true })
const store = init({
plugins: [loadingPlugin],
models: { example },
})
ReactDOM.render(
,
document.getElementById('root')
)
import React from 'react'
import ReactDOM from 'react-dom'
import { Provider } from 'react-redux'
import { init } from '@rematch/core'
import createLoadingPlugin from '@rematch/loading'
import App from './App'
import example from './example'
const loadingPlugin = createLoadingPlugin({ asNumber: true })
const store = init({
plugins: [loadingPlugin],
models: { example },
})
ReactDOM.render(
,
document.getElementById('root')
)
import { init } from '@rematch/core';
import { connectRouter, routerMiddleware } from 'connected-react-router';
import createLoadingPlugin from '@rematch/loading';
import createHistory from 'history/createBrowserHistory';
const options = {};
const loading = createLoadingPlugin(options);
export const history = createHistory();
const reducers = { router: connectRouter(history) };
/**
* 基于 Rematch 实现的 Redux 最佳实践 详情查看git了解
*
* More: https://rematch.gitbook.io/handbook/
*
* 顶层的store数据,返回给应用程序使用
*/
export default (models) => init({
redux: {
reducers,
middlewares: [