app-redux-utils
Advanced tools
Comparing version
@@ -1,2 +0,2 @@ | ||
import { AppAction } from "./types"; | ||
export declare function createAction(actionType: string, payload?: any): AppAction; | ||
import { IAppAction } from "./types"; | ||
export declare function createAction(actionType: string, payload?: any): IAppAction; |
@@ -10,4 +10,4 @@ import { AppAction } from "./types"; | ||
} | ||
return new AppAction(actionType, _payload); | ||
return new AppAction(actionType, _payload).toPlainObject(); | ||
} | ||
//# sourceMappingURL=createAction.js.map |
@@ -10,4 +10,7 @@ import { IAppAction } from "./IAppAction"; | ||
constructor(type: string, payload?: TPayload); | ||
static stop(appAction: IAppAction): void; | ||
static getActions(appAction: IAppAction): CallbackAction[]; | ||
stop(): void; | ||
getActions(): CallbackAction[]; | ||
toPlainObject(): IAppAction; | ||
} |
@@ -8,12 +8,12 @@ export class AppAction { | ||
} | ||
stop() { | ||
this.stopPropagation = true; | ||
static stop(appAction) { | ||
appAction.stopPropagation = true; | ||
} | ||
getActions() { | ||
static getActions(appAction) { | ||
const actions = []; | ||
if (typeof this.callbackAction === "function") { | ||
actions.push(this.callbackAction); | ||
if (typeof appAction.callbackAction === "function") { | ||
actions.push(appAction.callbackAction); | ||
} | ||
if (Array.isArray(this.actions) && this.actions.length > 0) { | ||
this.actions.forEach(action => { | ||
if (Array.isArray(appAction.actions) && appAction.actions.length > 0) { | ||
appAction.actions.forEach(action => { | ||
actions.push(() => action); | ||
@@ -24,3 +24,26 @@ }); | ||
} | ||
stop() { | ||
AppAction.stop(this); | ||
} | ||
getActions() { | ||
return AppAction.getActions(this); | ||
} | ||
toPlainObject() { | ||
const keys = Object.keys(this); | ||
const plainObject = {}; | ||
keys.forEach(key => { | ||
if (key !== "toPlainObject") { | ||
// @ts-ignore | ||
plainObject[key] = this[key]; | ||
} | ||
}); | ||
plainObject.stop = function () { | ||
AppAction.stop(this); | ||
}; | ||
plainObject.getActions = function () { | ||
return AppAction.getActions(this); | ||
}; | ||
return plainObject; | ||
} | ||
} | ||
//# sourceMappingURL=AppAction.js.map |
@@ -8,2 +8,4 @@ import { AnyAction } from "redux"; | ||
stopPropagation?: boolean; | ||
stop(): void; | ||
getActions(): CallbackAction[]; | ||
} |
@@ -1,3 +0,3 @@ | ||
import { AppAction } from "./AppAction"; | ||
declare function Reducer<TStore>(initialStore: TStore, updateActionType: string): (store: TStore | undefined, action: AppAction<any>) => TStore; | ||
import { IAppAction } from "./IAppAction"; | ||
declare function Reducer<TStore>(initialStore: TStore, updateActionType: string): (store: TStore | undefined, action: IAppAction<any>) => TStore; | ||
export { Reducer }; |
{ | ||
"name": "app-redux-utils", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Helpful utils for redux", | ||
@@ -5,0 +5,0 @@ "contributors": [ |
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
19234
8.86%153
22.4%