From bf4b5e76bd9985effbdd4d8a4b9f8b571e7968fe Mon Sep 17 00:00:00 2001 From: _haochuan Date: Wed, 24 Jul 2019 12:40:56 -0700 Subject: [PATCH] add optional args support in runloop.run (#37062) * add optional args support in runloop.run * add additional tests for runloop.run * remove trailing whitespace * remove trailing whitespace --- types/ember__runloop/ember__runloop-tests.ts | 20 ++++++++++++++++++++ types/ember__runloop/index.d.ts | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/types/ember__runloop/ember__runloop-tests.ts b/types/ember__runloop/ember__runloop-tests.ts index 37d1fc18e4..bd4d8492a1 100644 --- a/types/ember__runloop/ember__runloop-tests.ts +++ b/types/ember__runloop/ember__runloop-tests.ts @@ -20,6 +20,26 @@ function testRun() { return 123; }); + // run(target, method) + run({}, () => { + // code to be executed within a RunLoop + return 123; + }); + + // run(target, method, ...args) + run( + {}, + () => { + // code to be executed within a RunLoop + return 123; + }, + () => { + console.log('foo'); + }, + 'bar', + {} + ); + function destroyApp(application: EmberObject) { run(application, 'destroy'); run(application, function() { diff --git a/types/ember__runloop/index.d.ts b/types/ember__runloop/index.d.ts index 9f1fd6c260..4ec525add9 100644 --- a/types/ember__runloop/index.d.ts +++ b/types/ember__runloop/index.d.ts @@ -16,7 +16,7 @@ export interface RunNamespace { * end. */ (method: (...args: any[]) => Ret): Ret; - (target: Target, method: RunMethod): Ret; + (target: Target, method: RunMethod, ...args: any[]): Ret; /** * If no run-loop is present, it creates a new one. If a run loop is * present it will queue itself to run on the existing run-loops action