-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove function arg of promise macros
- Loading branch information
kellyselden
committed
Nov 15, 2016
1 parent
4ee5644
commit 704b389
Showing
6 changed files
with
75 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,13 @@ | ||
import Ember from 'ember'; | ||
import RSVP from 'rsvp'; | ||
import { resolveKeys } from './utils'; | ||
import { wrapPromiseProxy } from './utils'; | ||
|
||
const { | ||
ArrayProxy, | ||
PromiseProxyMixin | ||
} = Ember; | ||
|
||
const { resolve } = RSVP; | ||
|
||
const PromiseArray = ArrayProxy.extend(PromiseProxyMixin); | ||
|
||
export default function(key) { | ||
let shouldInvoke = typeof key === 'function'; | ||
|
||
return resolveKeys(key, function(value) { | ||
let promise; | ||
if (shouldInvoke) { | ||
promise = key.call(this); | ||
} else { | ||
promise = value; | ||
} | ||
|
||
if (promise === undefined) { | ||
promise = resolve(undefined); | ||
} | ||
|
||
return PromiseArray.create({ | ||
promise | ||
}); | ||
}); | ||
return wrapPromiseProxy(key, PromiseArray); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,13 @@ | ||
import Ember from 'ember'; | ||
import RSVP from 'rsvp'; | ||
import { resolveKeys } from './utils'; | ||
import { wrapPromiseProxy } from './utils'; | ||
|
||
const { | ||
ObjectProxy, | ||
PromiseProxyMixin | ||
} = Ember; | ||
|
||
const { resolve } = RSVP; | ||
|
||
const PromiseObject = ObjectProxy.extend(PromiseProxyMixin); | ||
|
||
export default function(key) { | ||
let shouldInvoke = typeof key === 'function'; | ||
|
||
return resolveKeys(key, function(value) { | ||
let promise; | ||
if (shouldInvoke) { | ||
promise = key.call(this); | ||
} else { | ||
promise = value; | ||
} | ||
|
||
if (promise === undefined) { | ||
promise = resolve(undefined); | ||
} | ||
|
||
return PromiseObject.create({ | ||
promise | ||
}); | ||
}); | ||
return wrapPromiseProxy(key, PromiseObject); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.