import { init, RematchDispatch, RematchRootState, RematchStore } from '@rematch/core'
import immerPlugin from '@rematch/immer'

import { models, RootModel } from './models'


export type Store = RematchStore<RootModel, Record<string, never>>
export type Dispatch = RematchDispatch<RootModel>
export type RootState = RematchRootState<RootModel>

export const store: Store = init({
  models,
  plugins: [immerPlugin()],
  redux: {
    devtoolOptions: {
      actionSanitizer: (action) => action
    },
    rootReducers: { RESET_APP: () => undefined }
  }
})
