mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-23 05:58:26 +08:00
refactor(helpers): update domControllerAsync to make callback optional and work off of a Promise
This commit is contained in:
@ -275,11 +275,15 @@ export function playAnimationAsync(animation: Animation): Promise<Animation> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function domControllerAsync(domControllerFunction: Function, callback: Function) {
|
export function domControllerAsync(domControllerFunction: Function, callback?: Function): Promise<any> {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
domControllerFunction(() => {
|
domControllerFunction(() => {
|
||||||
callback();
|
if (!callback) {
|
||||||
resolve();
|
return resolve();
|
||||||
|
}
|
||||||
|
Promise.resolve(callback()).then((...args: any[]) => {
|
||||||
|
resolve(args);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user