@featherweight/store-preset-slim
v0.0.2
Published
Featherweight store slim preset
Downloads
2
Readme
Featherweight Store slim preset
Featherweight store with Redux Logger and Thunk.
Setup
npm install @featherweight/store-preset-slim
API
configureStore()
function configureStore({
devTools: boolean,
enhancers: Array<StoreEnhancer>,
forLogger: Object,
forThunk: any,
initialState: State,
middlewares: Array<Middleware>,
production: boolean,
reducer: Object<string, Reducer> | Reducer,
})
devTools: boolean
Indicates if Redux DevTools should be enabled. Defaults to true
.
enhancers: Array<StoreEnhancer>
Enhancers to apply. Defaults to []
forLogger: Object
Options for Redux Logger. Defaults to {}
forThunk: any
Extra argument to pass to Redux Thunk.
initialState: State
Initial state that will be passed to createStore
middlewares: Array<Middleware>
An array of Redux middlewares to overwrite the default ones: [logger, thunk]
.
production: boolean
When true
disables development-only features. By default will check process.env.NODE_ENV
.
reducer: Object<string, Reducer> | Reducer
An object with slice reducers or just a reducer function (required).
getLogger
You can import preconfigured Redux Logger separately.
getLogger
accepts the same options as redux-logger
's createLogger()
.
import { getLogger } from '@featherweight/store-preset-slim'
const middlewares = [
getLogger(),
/* or with some options */
getLogger({ timestamp: true }),
/* other middlewares... */
]
getMiddlewares
If you want to add some middleware to default set you can use getMiddlewares()
which will return an array with [logger, thunk]
. Accepts options: forLogger
, forThunk
, production
.
import { getMiddlewares } from '@featherweight/store-preset-slim'
const middlewares = [
getMiddlewares(),
/* or with some options */
getMiddlewares({ forLogger: { timestamp: true } }),
/* other middlewares... */
]