breaking change(Dialog): adjust before-close usage

This commit is contained in:
chenjiahan
2020-09-06 10:16:54 +08:00
parent c9f0f11028
commit 21c30cbbf8
6 changed files with 49 additions and 34 deletions
+7 -2
View File
@@ -2,10 +2,11 @@ import { isPromise, noop } from '.';
export function callInterceptor(options: {
interceptor?: (...args: any[]) => Promise<boolean> | boolean;
done: () => void;
args: any[];
done: () => void;
canceled?: () => void;
}) {
const { interceptor, args, done } = options;
const { interceptor, args, done, canceled } = options;
if (interceptor) {
const returnVal = interceptor(...args);
@@ -15,11 +16,15 @@ export function callInterceptor(options: {
.then((value) => {
if (value) {
done();
} else if (canceled) {
canceled();
}
})
.catch(noop);
} else if (returnVal) {
done();
} else if (canceled) {
canceled();
}
} else {
done();