app-redux-utils
Advanced tools
Comparing version 1.5.4 to 1.6.0
@@ -1,6 +0,9 @@ | ||
import { Store } from 'redux'; | ||
import { Dispatch, Middleware } from 'redux'; | ||
import { Container } from 'cheap-di'; | ||
import { Action } from '../types'; | ||
import { Watcher } from './Watcher'; | ||
declare function controllerMiddleware<State>(watchers: Watcher<State, any>[], container?: Container): (reduxStore: Store<State, Action>) => (next: (action: Action) => void) => (action: Action) => Promise<void>; | ||
declare type MiddlewareOptions<State> = { | ||
watchers?: Watcher<State, any>[]; | ||
container?: Container; | ||
}; | ||
declare function controllerMiddleware<State>(options?: MiddlewareOptions<State>): Middleware<Dispatch, State>; | ||
export { controllerMiddleware }; |
@@ -8,8 +8,9 @@ "use strict"; | ||
const types_1 = require("../types"); | ||
function controllerMiddleware(watchers, container) { | ||
return (reduxStore) => (next) => (action) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { | ||
function controllerMiddleware(options = {}) { | ||
const { watchers = [], container, } = options; | ||
return (middlewareAPI) => (next) => (action) => tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
next(action); | ||
let createController; | ||
if (container) { | ||
container.registerInstance(reduxStore).as(AbstractStore_1.AbstractStore); | ||
container.registerInstance(middlewareAPI).as(AbstractStore_1.AbstractStore); | ||
createController = (watcher) => { | ||
@@ -24,3 +25,3 @@ const internalDependencies = container.dependencies; | ||
else { | ||
createController = (watcher) => watcher.instance(reduxStore); | ||
createController = (watcher) => watcher.instance(middlewareAPI); | ||
} | ||
@@ -27,0 +28,0 @@ if (!(0, types_1.isAction)(action)) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
(0, tslib_1.__exportStar)(require("./ControllerBase"), exports); | ||
(0, tslib_1.__exportStar)(require("./controllerMiddleware"), exports); | ||
(0, tslib_1.__exportStar)(require("./Watcher"), exports); | ||
tslib_1.__exportStar(require("./ControllerBase"), exports); | ||
tslib_1.__exportStar(require("./controllerMiddleware"), exports); | ||
tslib_1.__exportStar(require("./Watcher"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -1,3 +0,3 @@ | ||
import { Store } from 'redux'; | ||
import { Action, Controller } from '../types'; | ||
import { Dispatch, MiddlewareAPI } from 'redux'; | ||
import { Controller } from '../types'; | ||
import { ControllerBase } from './ControllerBase'; | ||
@@ -7,7 +7,7 @@ declare type Watcher<State, TController extends Controller> = { | ||
get: (actionType: string) => (keyof TController) | undefined; | ||
instance: (reduxStore: Store<State, Action>) => ControllerBase<State>; | ||
type: new (reduxStore: Store<State, Action>, ...args: any[]) => ControllerBase<State>; | ||
instance: (middlewareAPI: MiddlewareAPI<Dispatch, State>) => ControllerBase<State>; | ||
type: new (middlewareAPI: MiddlewareAPI<Dispatch, State>, ...args: any[]) => ControllerBase<State>; | ||
}; | ||
declare function watcher<State, TController extends Controller>(Controller: new (reduxStore: Store<State, Action>, ...args: any[]) => ControllerBase<State>, watchList: [string, keyof TController][]): Watcher<State, TController>; | ||
declare function watcher<State, TController extends Controller>(Controller: new (middlewareAPI: MiddlewareAPI<Dispatch, State>, ...args: any[]) => ControllerBase<State>, watchList: [string, keyof TController][]): Watcher<State, TController>; | ||
export { watcher }; | ||
export type { Watcher }; |
@@ -9,3 +9,3 @@ "use strict"; | ||
get: (actionType) => map.get(actionType), | ||
instance: (reduxStore) => new Controller(reduxStore), | ||
instance: (middlewareAPI) => new Controller(middlewareAPI), | ||
type: Controller, | ||
@@ -12,0 +12,0 @@ }; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
(0, tslib_1.__exportStar)(require("./watch"), exports); | ||
tslib_1.__exportStar(require("./watch"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -5,12 +5,12 @@ "use strict"; | ||
const tslib_1 = require("tslib"); | ||
(0, tslib_1.__exportStar)(require("./AbstractStore"), exports); | ||
(0, tslib_1.__exportStar)(require("./controller"), exports); | ||
(0, tslib_1.__exportStar)(require("./createAction"), exports); | ||
(0, tslib_1.__exportStar)(require("./createActionWithCallback"), exports); | ||
(0, tslib_1.__exportStar)(require("./createReducers"), exports); | ||
tslib_1.__exportStar(require("./AbstractStore"), exports); | ||
tslib_1.__exportStar(require("./controller"), exports); | ||
tslib_1.__exportStar(require("./createAction"), exports); | ||
tslib_1.__exportStar(require("./createActionWithCallback"), exports); | ||
tslib_1.__exportStar(require("./createReducers"), exports); | ||
var types_1 = require("./types"); | ||
Object.defineProperty(exports, "isAction", { enumerable: true, get: function () { return types_1.isAction; } }); | ||
(0, tslib_1.__exportStar)(require("./Reducer"), exports); | ||
(0, tslib_1.__exportStar)(require("./decorators"), exports); | ||
(0, tslib_1.__exportStar)(require("./symbols"), exports); | ||
tslib_1.__exportStar(require("./Reducer"), exports); | ||
tslib_1.__exportStar(require("./decorators"), exports); | ||
tslib_1.__exportStar(require("./symbols"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -1,3 +0,3 @@ | ||
import { Action } from './types'; | ||
declare function Reducer<TStore>(initialStore: TStore, updateActionType: string): (store: TStore | undefined, action: Action) => TStore; | ||
import { Reducer as ReduxReducer, AnyAction } from 'redux'; | ||
declare function Reducer<TStore>(initialStore: TStore, updateActionType: string): ReduxReducer<TStore, AnyAction>; | ||
export { Reducer }; |
@@ -5,3 +5,3 @@ "use strict"; | ||
function Reducer(initialStore, updateActionType) { | ||
return (store = initialStore, action) => { | ||
return ((store = initialStore, action) => { | ||
if (action.type !== updateActionType) { | ||
@@ -14,5 +14,5 @@ return store; | ||
return Object.assign({}, store); | ||
}; | ||
}); | ||
} | ||
exports.Reducer = Reducer; | ||
//# sourceMappingURL=Reducer.js.map |
@@ -1,5 +0,5 @@ | ||
import { Action as ReduxAction } from 'redux'; | ||
import { AnyAction } from 'redux'; | ||
import { Watcher } from './controller'; | ||
import { controllerWatcherSymbol, inheritancePreserveSymbol, watchersSymbol } from './symbols'; | ||
interface Action<TPayload = any> extends ReduxAction { | ||
interface Action<TPayload = any> extends AnyAction { | ||
payload: TPayload; | ||
@@ -34,5 +34,5 @@ callbackAction?: CallbackAction; | ||
declare type WatchedController<TController extends Controller> = { | ||
[methodName in keyof TController]: TController[methodName] extends (param: infer Param) => any ? Param extends Action<infer ActionType> ? ActionType extends NonNullable<any> ? (param: ActionType) => Action<ActionType> : () => Action : (...params: Parameters<TController[methodName]>) => Action : TController[methodName]; | ||
[methodName in keyof TController]: TController[methodName] extends (parameter: infer MethodParameter) => any ? MethodParameter extends Action<infer Payload> ? Payload extends NonNullable<any> ? (payload: Payload) => Action<Payload> : () => Action : (...params: Parameters<TController[methodName]>) => Action : TController[methodName]; | ||
}; | ||
export type { Controller, Action, ActionWithCallback, CallbackAction, Constructor, WatchedConstructor, DecoratedWatchedController, WatchedController, }; | ||
export { isAction }; |
{ | ||
"name": "app-redux-utils", | ||
"version": "1.5.4", | ||
"version": "1.6.0", | ||
"description": "Helpful utils for redux", | ||
@@ -26,15 +26,15 @@ "contributors": [ | ||
"dependencies": { | ||
"redux": "4.1.1", | ||
"redux": "4.2.0", | ||
"reflect-metadata": "0.1.13" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "27.0.1", | ||
"@typescript-eslint/eslint-plugin": "4.31.1", | ||
"@typescript-eslint/parser": "4.31.1", | ||
"@types/jest": "27.4.1", | ||
"@typescript-eslint/eslint-plugin": "5.21.0", | ||
"@typescript-eslint/parser": "5.21.0", | ||
"cheap-di": "3.2.1", | ||
"eslint": "7.32.0", | ||
"eslint-plugin-sonarjs": "0.10.0", | ||
"jest": "27.2.0", | ||
"ts-jest": "27.0.5", | ||
"typescript": "4.4.3" | ||
"eslint": "8.14.0", | ||
"eslint-plugin-sonarjs": "0.13.0", | ||
"jest": "28.0.3", | ||
"ts-jest": "27.1.4", | ||
"typescript": "4.6.4" | ||
}, | ||
@@ -44,3 +44,4 @@ "repository": { | ||
"url": "https://github.com/TomasLight/app-redux-utils" | ||
} | ||
}, | ||
"packageManager": "yarn@3.2.0" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
46735
54
504
+ Addedredux@4.2.0(transitive)
- Removedredux@4.1.1(transitive)
Updatedredux@4.2.0