different import type
This commit is contained in:
parent
55e65bd5d8
commit
ac53f1d24b
15
src/Updux.ts
15
src/Updux.ts
@ -1,11 +1,8 @@
|
||||
import {
|
||||
import * as rtk from '@reduxjs/toolkit';
|
||||
const {
|
||||
configureStore,
|
||||
EnhancedStore,
|
||||
Action,
|
||||
PayloadAction,
|
||||
AnyAction,
|
||||
ActionCreatorWithPreparedPayload,
|
||||
} from '@reduxjs/toolkit';
|
||||
} = rtk;
|
||||
import { Action, AnyAction, EnhancedStore, PayloadAction } from '@reduxjs/toolkit';
|
||||
import {
|
||||
AugmentedMiddlewareAPI,
|
||||
DuxActions,
|
||||
@ -166,7 +163,7 @@ export default class Updux<D extends DuxConfig> {
|
||||
>,
|
||||
terminal?: boolean,
|
||||
): Updux<D>;
|
||||
addMutation<AC extends ActionCreatorWithPreparedPayload<any, any, string, never, never>>(
|
||||
addMutation<AC extends rtk.ActionCreatorWithPreparedPayload<any, any, string, never, never>>(
|
||||
actionCreator: AC,
|
||||
mutation: Mutation<ReturnType<AC>, DuxState<D>>,
|
||||
terminal?: boolean
|
||||
@ -242,7 +239,7 @@ export default class Updux<D extends DuxConfig> {
|
||||
DuxActions<D>[A] extends (...args: any[]) => infer R ? R : AnyAction
|
||||
>,
|
||||
): Updux<D>;
|
||||
addEffect<AC extends ActionCreatorWithPreparedPayload<any, any, string, never, never>>(
|
||||
addEffect<AC extends rtk.ActionCreatorWithPreparedPayload<any, any, string, never, never>>(
|
||||
actionCreator: AC,
|
||||
effect: EffectMiddleware<D, ReturnType<AC>>,
|
||||
): Updux<D>;
|
||||
|
@ -1,15 +1,13 @@
|
||||
import { AnyAction } from '@reduxjs/toolkit';
|
||||
import { Dispatch } from '@reduxjs/toolkit';
|
||||
import { MiddlewareAPI } from '@reduxjs/toolkit';
|
||||
import * as rtk from '@reduxjs/toolkit';
|
||||
import { augmentGetState } from './createStore.js';
|
||||
import { AugmentedMiddlewareAPI } from './types.js';
|
||||
|
||||
//const composeMw = (mws) => (api) => (originalNext) =>
|
||||
// mws.reduceRight((next, mw) => mw(api)(next), originalNext);
|
||||
|
||||
export interface EffectMiddleware<D, A = AnyAction> {
|
||||
export interface EffectMiddleware<D, A = rtk.AnyAction> {
|
||||
(api: AugmentedMiddlewareAPI<D>): (
|
||||
next: Dispatch<AnyAction>,
|
||||
next: rtk.Dispatch<rtk.AnyAction>,
|
||||
) => (action: A) => any;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
import Updux from './Updux.js';
|
||||
|
||||
export { withPayload } from './actions.js';
|
||||
export { createAction } from '@reduxjs/toolkit';
|
||||
export { withPayload, createAction } from './actions.js';
|
||||
|
||||
export default Updux;
|
||||
|
@ -1,12 +1,12 @@
|
||||
import * as R from 'remeda';
|
||||
import u from '@yanick/updeep-remeda';
|
||||
import { AnyAction } from '@reduxjs/toolkit';
|
||||
import * as rtk from '@reduxjs/toolkit';
|
||||
import { DuxConfig, Mutation } from './types.js';
|
||||
import { D } from '@mobily/ts-belt';
|
||||
import Updux from './Updux.js';
|
||||
|
||||
export type MutationCase = {
|
||||
matcher: (action: AnyAction) => boolean;
|
||||
matcher: (action: rtk.AnyAction) => boolean;
|
||||
mutation: Mutation;
|
||||
terminal: boolean;
|
||||
};
|
||||
@ -22,7 +22,7 @@ export function buildReducer(
|
||||
// TODO matcherMutation
|
||||
// TODO defaultMutation
|
||||
//
|
||||
const reducer = (state = initialStateState, action: AnyAction) => {
|
||||
const reducer = (state = initialStateState, action: rtk.AnyAction) => {
|
||||
if (!action?.type) throw new Error('reducer called with a bad action');
|
||||
|
||||
let active = mutations.filter(({ matcher }) => matcher(action));
|
||||
|
Loading…
Reference in New Issue
Block a user