type fixes
This commit is contained in:
parent
8d4542fffa
commit
5c5e614f4b
@ -1,7 +1,7 @@
|
|||||||
import fp from 'lodash/fp';
|
import fp from 'lodash/fp';
|
||||||
|
|
||||||
import { Middleware, MiddlewareAPI, Dispatch } from 'redux';
|
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 => {
|
const MiddlewareFor = (type: any, mw: Middleware ): Middleware => api => next => action => {
|
||||||
if (type !== '*' && action.type !== type) return 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>(
|
function buildMiddleware<S=any>(
|
||||||
effects : Dictionary<Middleware<{},S,UpduxDispatch>>= {},
|
effects : Dictionary<UpduxMiddleware<S>>= {},
|
||||||
actions : Dictionary<ActionCreator>= {},
|
actions : Dictionary<ActionCreator>= {},
|
||||||
subduxes :any = {},
|
subduxes :any = {},
|
||||||
): UpduxMiddleware<S>
|
): UpduxMiddleware<S>
|
||||||
@ -33,7 +33,7 @@ function buildMiddleware<S=any>(
|
|||||||
fp.map( ([ slice, mw ]: [ string, Middleware]) => sliceMw(slice,mw) )
|
fp.map( ([ slice, mw ]: [ string, Middleware]) => sliceMw(slice,mw) )
|
||||||
)( subduxes );
|
)( subduxes );
|
||||||
|
|
||||||
return (api: MiddlewareAPI<UpduxDispatch,S>) => {
|
return (api: UpduxMiddlewareAPI<S>) => {
|
||||||
|
|
||||||
for (let type in actions) {
|
for (let type in actions) {
|
||||||
const ac = actions[type];
|
const ac = actions[type];
|
||||||
|
@ -17,6 +17,7 @@ import {
|
|||||||
Mutation,
|
Mutation,
|
||||||
Upreducer,
|
Upreducer,
|
||||||
UpduxDispatch,
|
UpduxDispatch,
|
||||||
|
UpduxMiddleware
|
||||||
} from './types';
|
} from './types';
|
||||||
|
|
||||||
import {Middleware, Store} from 'redux';
|
import {Middleware, Store} from 'redux';
|
||||||
@ -98,7 +99,7 @@ export class Updux<S = any> {
|
|||||||
groomMutations: (mutation: Mutation<S>) => Mutation<S>;
|
groomMutations: (mutation: Mutation<S>) => Mutation<S>;
|
||||||
|
|
||||||
@observable private localEffects: Dictionary<
|
@observable private localEffects: Dictionary<
|
||||||
Middleware<{}, S, UpduxDispatch>
|
UpduxMiddleware<S>
|
||||||
>;
|
>;
|
||||||
|
|
||||||
@observable private localActions: Dictionary<ActionCreator>;
|
@observable private localActions: Dictionary<ActionCreator>;
|
||||||
@ -136,7 +137,7 @@ export class Updux<S = any> {
|
|||||||
* local updux. The function `getRootState` is provided
|
* local updux. The function `getRootState` is provided
|
||||||
* alongside `getState` to get the root state.
|
* alongside `getState` to get the root state.
|
||||||
*/
|
*/
|
||||||
@computed get middleware(): Middleware<{}, S, UpduxDispatch> {
|
@computed get middleware(): UpduxMiddleware<S> {
|
||||||
return buildMiddleware(
|
return buildMiddleware(
|
||||||
this.localEffects,
|
this.localEffects,
|
||||||
this.actions,
|
this.actions,
|
||||||
|
Loading…
Reference in New Issue
Block a user