neuro-store
Version:
37 lines (34 loc) • 863 B
TypeScript
/** [----createStore----]
* @example
* // basic middleware example
* const middleware = ({ dispatch, getState }: any) => (next: any) =>(action: any) => {
* if (typeof action === "function") {
* return action(dispatch, getState);
* }
* return next(action);
* };
* @example
* // basic store
* const reducers = {
auth: authSlice.reducer,
};
type Reducers = typeof reducers;
type State = {
[K in keyof Reducers]: ReturnType<Reducers[K]>;
};
type Middleware = [];
const store = createStore<State, Reducers, Middleware>({
reducers: reducers,
middlewares: [],
});
*
*/
declare function createStore<S, R, M>(store: {
reducers: R;
middlewares: M;
}): {
initialState: S;
reducers: (state: any, action: any) => unknown;
middlewares: M;
};
export { createStore };