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
This commit is contained in:
_haochuan 2019-07-24 12:40:56 -07:00 committed by Wesley Wigham
parent 70ba0dd2b4
commit bf4b5e76bd
2 changed files with 21 additions and 1 deletions

View File

@ -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() {

View File

@ -16,7 +16,7 @@ export interface RunNamespace {
* end.
*/
<Ret>(method: (...args: any[]) => Ret): Ret;
<Target, Ret>(target: Target, method: RunMethod<Target, Ret>): Ret;
<Target, Ret>(target: Target, method: RunMethod<Target, Ret>, ...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