@omnia/fx-models 7.8.103-preview → 7.8.104-preview
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -15,6 +15,8 @@ export declare class Future<T> extends Promise<T> {
|
|
|
15
15
|
* @memberof Future
|
|
16
16
|
*/
|
|
17
17
|
tryCatch(): Future<[success: T, error: Error]>;
|
|
18
|
+
unwrapAxiosApiResponse<T2>(): Future<T2>;
|
|
19
|
+
unwrap<T2>(executor: (value: T, resolve: (value: T2) => void, reject: (reason?: any) => void) => void): Future<T2>;
|
|
18
20
|
/**
|
|
19
21
|
* Expose abort for other future to use.
|
|
20
22
|
* chain method for future
|
|
@@ -53,6 +53,28 @@ class Future extends Promise {
|
|
|
53
53
|
}
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
|
+
unwrapAxiosApiResponse() {
|
|
57
|
+
return new Future((resolve, reject, abort) => {
|
|
58
|
+
this.abortIf(abort);
|
|
59
|
+
return this.then(response => {
|
|
60
|
+
const apiResponse = response;
|
|
61
|
+
if (apiResponse?.data.success) {
|
|
62
|
+
resolve(apiResponse.data.data);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
reject(apiResponse.data.errorMessage);
|
|
66
|
+
}
|
|
67
|
+
}).catch(() => {
|
|
68
|
+
reject();
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
unwrap(executor) {
|
|
73
|
+
return new Future((resolve, reject, abort) => {
|
|
74
|
+
this.abortIf(abort);
|
|
75
|
+
return this.then(q => executor(q, resolve, reject));
|
|
76
|
+
});
|
|
77
|
+
}
|
|
56
78
|
/**
|
|
57
79
|
* Expose abort for other future to use.
|
|
58
80
|
* chain method for future
|
package/package.json
CHANGED