From b804c552ba8f8dc4739a2ae37a230c05d72fc0d2 Mon Sep 17 00:00:00 2001 From: Dan Bucholtz Date: Thu, 21 Dec 2017 12:50:19 -0600 Subject: [PATCH] refactor(helpers): update domControllerAsync to make callback optional and work off of a Promise --- packages/core/src/utils/helpers.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/core/src/utils/helpers.ts b/packages/core/src/utils/helpers.ts index 04a25295b9..42bf31f1c8 100644 --- a/packages/core/src/utils/helpers.ts +++ b/packages/core/src/utils/helpers.ts @@ -275,11 +275,15 @@ export function playAnimationAsync(animation: Animation): Promise { }); } -export function domControllerAsync(domControllerFunction: Function, callback: Function) { +export function domControllerAsync(domControllerFunction: Function, callback?: Function): Promise { return new Promise((resolve) => { domControllerFunction(() => { - callback(); - resolve(); + if (!callback) { + return resolve(); + } + Promise.resolve(callback()).then((...args: any[]) => { + resolve(args); + }); }); }); }