Compare commits

..

2 Commits

Author SHA1 Message Date
90e90779e1 remove unused dependencies 2024-08-09 10:31:03 -04:00
ac53f1d24b different import type 2024-08-09 10:27:41 -04:00
5 changed files with 16 additions and 29 deletions

View File

@ -1,12 +1,12 @@
{
"version": "4.0.0-alpha.4",
"type": "module",
"dependencies": {
"@mobily/ts-belt": "4.0.0-rc.5",
"@yanick/updeep-remeda": "^2.3.1",
"immer": "^9.0.15",
"json-schema-shorthand": "^2.0.0",
"json-schema-to-ts": "^2.9.2",
"memoize-one": "^6.0.0",
"@reduxjs/toolkit": "^2.2.7",
"moize": "^6.1.6",
"redux": "^4.2.0",
"remeda": "^1.0.1",
@ -22,10 +22,7 @@
},
"name": "updux",
"description": "Updeep-friendly Redux helper framework",
"scripts": {
"docsify:serve": "docsify serve docs"
},
"version": "4.0.0-alpha.3",
"scripts": {},
"repository": {
"type": "git",
"url": "git+https://github.com/yanick/updux.git"
@ -40,17 +37,13 @@
},
"homepage": "https://github.com/yanick/updux#readme",
"devDependencies": {
"@reduxjs/toolkit": "^2.2.7",
"@vitest/browser": "^0.23.1",
"@vitest/ui": "^2.0.5",
"docsify": "^4.13.1",
"eslint": "^8.22.0",
"eslint-plugin-no-only-tests": "^3.0.0",
"eslint-plugin-todo-plz": "^1.2.1",
"jsdoc-to-markdown": "^7.1.1",
"prettier": "^2.7.1",
"redux-toolkit": "^1.1.2",
"tsdoc-markdown": "^0.0.4",
"typedoc": "^0.25.9",
"typedoc-plugin-markdown": "^3.17.1",
"typescript": "^4.9.5",

View File

@ -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>;

View File

@ -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;
}

View File

@ -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;

View File

@ -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));