Skip to content

Commit a8d752a

Browse files
committed
Add: Adding three others method into builder case class to handle the different case for an async action
1 parent 00259a4 commit a8d752a

File tree

14 files changed

+102
-15
lines changed

14 files changed

+102
-15
lines changed

.npmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
node_modules
22
src
33
tsconfig.json
4+
.babelrc
5+
yarn.lock

dist/hooks/useAsyncActions.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/hooks/useAsyncActions.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import GXProvider from "./providers/index.js";
2+
import { AsyncActionStatuses } from "./helpers/types.js";
23
import createSignal from "./helpers/createSignal.js";
34
import createStore from "./helpers/createStore.js";
45
import createAsyncAction from "./helpers/createAsyncAction.js";
@@ -8,4 +9,4 @@ import useAsyncActions from "./hooks/useAsyncActions.js";
89
import useSignal from "./hooks/useSignal.js";
910
import useOperations from "./hooks/useOperations.js";
1011
export default GXProvider;
11-
export { createSignal, createStore, createAsyncAction, useAction, useActions, useAsyncActions, useSignal, useOperations, };
12+
export { createSignal, createStore, createAsyncAction, useAction, useActions, useAsyncActions, useSignal, useOperations, AsyncActionStatuses };

dist/index.js

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/interfaces/builderCase.d.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import { AsyncActionStatusesType, CreateAsyncActionReturnType } from "../helpers
44
*/
55
export default interface IBuilderCase<T, P = any> {
66
case(status: AsyncActionStatusesType, handler: (state: T, payload?: P) => T): IBuilderCase<T, P>;
7+
onPending(handler: (state: T, payload?: P) => T): IBuilderCase<T, P>;
8+
onFulfilled(handler: (state: T, payload?: P) => T): IBuilderCase<T, P>;
9+
onRejected(handler: (state: T, payload?: P) => T): IBuilderCase<T, P>;
710
}
811
/**
912
* Builder case class for managing different cases of the asynchronous task
@@ -37,6 +40,24 @@ export declare class BuilderCase<T, P = any> implements IBuilderCase<T, P> {
3740
* @returns
3841
*/
3942
case(status: AsyncActionStatusesType, handler: (state: T, payload?: P) => T): IBuilderCase<T, P>;
43+
/**
44+
* Method that add a pending case into the _cases list and return a new case builder object
45+
* @param handler Function that is executed depending on the specific status
46+
* @returns
47+
*/
48+
onPending(handler: (state: T, payload?: P) => T): IBuilderCase<T, P>;
49+
/**
50+
* Method that add a fulfilled case into the _cases list and return a new case builder object
51+
* @param handler Function that is executed depending on the specific status
52+
* @returns
53+
*/
54+
onFulfilled(handler: (state: T, payload?: P) => T): IBuilderCase<T, P>;
55+
/**
56+
* Method that add a rejected case into the _cases list and return a new case builder object
57+
* @param handler Function that is executed depending on the specific status
58+
* @returns
59+
**/
60+
onRejected(handler: (state: T, payload?: P) => T): IBuilderCase<T, P>;
4061
}
4162
/**
4263
* Case interface

dist/interfaces/builderCase.js

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/interfaces/builderCase.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/providers/reducer.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)