type fixes

This commit is contained in:
Yanick Champoux 2019-11-06 19:06:54 -05:00
parent 8d4542fffa
commit 5c5e614f4b
2 changed files with 6 additions and 5 deletions

View File

@ -1,7 +1,7 @@
import fp from 'lodash/fp';
import { Middleware, MiddlewareAPI, Dispatch } from 'redux';
import { Dictionary, ActionCreator, Action, UpduxDispatch, UpduxMiddleware } from '../types';
import { Dictionary, ActionCreator, Action, UpduxDispatch, UpduxMiddleware, UpduxMiddlewareAPI } from '../types';
const MiddlewareFor = (type: any, mw: Middleware ): Middleware => api => next => action => {
if (type !== '*' && action.type !== type) return next(action);
@ -20,7 +20,7 @@ function sliceMw( slice: string, mw: Middleware ): Middleware {
}
function buildMiddleware<S=any>(
effects : Dictionary<Middleware<{},S,UpduxDispatch>>= {},
effects : Dictionary<UpduxMiddleware<S>>= {},
actions : Dictionary<ActionCreator>= {},
subduxes :any = {},
): UpduxMiddleware<S>
@ -33,7 +33,7 @@ function buildMiddleware<S=any>(
fp.map( ([ slice, mw ]: [ string, Middleware]) => sliceMw(slice,mw) )
)( subduxes );
return (api: MiddlewareAPI<UpduxDispatch,S>) => {
return (api: UpduxMiddlewareAPI<S>) => {
for (let type in actions) {
const ac = actions[type];

View File

@ -17,6 +17,7 @@ import {
Mutation,
Upreducer,
UpduxDispatch,
UpduxMiddleware
} from './types';
import {Middleware, Store} from 'redux';
@ -98,7 +99,7 @@ export class Updux<S = any> {
groomMutations: (mutation: Mutation<S>) => Mutation<S>;
@observable private localEffects: Dictionary<
Middleware<{}, S, UpduxDispatch>
UpduxMiddleware<S>
>;
@observable private localActions: Dictionary<ActionCreator>;
@ -136,7 +137,7 @@ export class Updux<S = any> {
* local updux. The function `getRootState` is provided
* alongside `getState` to get the root state.
*/
@computed get middleware(): Middleware<{}, S, UpduxDispatch> {
@computed get middleware(): UpduxMiddleware<S> {
return buildMiddleware(
this.localEffects,
this.actions,