apani-dukaan-redux-factory
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -13,15 +13,10 @@ import { Store, Reducer, Action, StoreEnhancer } from "redux"; | ||
export declare const getActionName: (prefix: string, name: string) => string; | ||
export declare const getDataAction: <T>(prefix: string, name: string) => { | ||
reset: ActionFunctionAny<import("redux-actions").Action<any>>; | ||
init: ActionFunctionAny<import("redux-actions").Action<any>>; | ||
failed: ActionFunction1<IDataError, import("redux-actions").Action<IDataError>>; | ||
success: ActionFunction1<T, import("redux-actions").Action<T>>; | ||
}; | ||
export interface IActions<T> { | ||
export declare const getDataAction: <T, E = IDataError>(prefix: string, name: string) => IActions<T, E>; | ||
export interface IActions<T, E = IDataError> { | ||
reset: ActionFunctionAny<Action<unknown>>; | ||
init: ActionFunctionAny<Action<unknown>>; | ||
failed: ActionFunction1<IDataError, Action<IDataError>>; | ||
failed: ActionFunction1<E, Action<E>>; | ||
success: ActionFunction1<T, Action<T>>; | ||
} | ||
export declare const addDataActions: <T>(actions: IActions<T>, key: string) => (reducerFactory: ReducerFactory<any, any>) => void; | ||
export declare const addDataActions: <T, E = IDataError>(actions: IActions<T, E>, key: string) => (reducerFactory: ReducerFactory<any, any>) => void; | ||
export default store; |
{ | ||
"name": "apani-dukaan-redux-factory", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "lib for redux", | ||
@@ -5,0 +5,0 @@ "main": "build/", |
// Libraries | ||
import { | ||
createStore, | ||
Store, | ||
Reducer, | ||
Action, | ||
StoreEnhancer, | ||
} from "redux"; | ||
import { createStore, Store, Reducer, Action, StoreEnhancer } from "redux"; | ||
import { logger } from "redux-logger"; | ||
@@ -42,19 +36,25 @@ import { | ||
export const getDataAction = <T>(prefix: string, name: string) => { | ||
return { | ||
export const getDataAction = <T, E = IDataError>( | ||
prefix: string, | ||
name: string | ||
) => { | ||
return ({ | ||
reset: createAction(getActionName(prefix, `${name}_RESET`)), | ||
init: createAction(getActionName(prefix, `${name}_INIT`)), | ||
failed: createAction<IDataError>(getActionName(prefix, `${name}_FAILED`)), | ||
success: createAction<T>(getActionName(prefix, `${name}_SUCCESS`)), | ||
}; | ||
failed: createAction<E>(getActionName(prefix, `${name}_FAILED`)), | ||
success: createAction(getActionName(prefix, `${name}_SUCCESS`)), | ||
} as unknown) as IActions<T, E>; | ||
}; | ||
export interface IActions<T> { | ||
export interface IActions<T, E = IDataError> { | ||
reset: ActionFunctionAny<Action<unknown>>; | ||
init: ActionFunctionAny<Action<unknown>>; | ||
failed: ActionFunction1<IDataError, Action<IDataError>>; | ||
failed: ActionFunction1<E, Action<E>>; | ||
success: ActionFunction1<T, Action<T>>; | ||
} | ||
export const addDataActions = <T>(actions: IActions<T>, key: string) => { | ||
export const addDataActions = <T, E = IDataError>( | ||
actions: IActions<T, E>, | ||
key: string | ||
) => { | ||
return (reducerFactory: ReducerFactory<any, any>) => { | ||
@@ -61,0 +61,0 @@ reducerFactory.add(actions.reset.toString(), (state) => { |
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
13140
275