mirror of
https://github.com/flynx/types.js.git
synced 2025-10-29 02:20:07 +00:00
notes and claenup...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
5a94971caa
commit
4e5753a228
15
Promise.js
15
Promise.js
@ -799,24 +799,27 @@ object.Constructor('ProxyPromise', Promise, {
|
||||
// XXX DOCS...
|
||||
// XXX like promise but if a value can be generated sync then this will
|
||||
// run in sync otherwise it will fall back to being a promise...
|
||||
// XXX potential problem is recursion (depth) on the sync stage...
|
||||
// XXX should we throw errors in sync mode???
|
||||
// XXX should we throw errors in sync mode??? ...option???
|
||||
var MaybePromise =
|
||||
module.MaybePromise =
|
||||
object.Constructor('MaybePromise', Promise, {
|
||||
//error: undefined,
|
||||
//value: undefined,
|
||||
//error: undefined,
|
||||
|
||||
// NOTE: if this is called it means that .__new__(..) returned in sync
|
||||
// mode and thus set .value and possibly .error, soe there is no
|
||||
// need to check for .value...
|
||||
then: function(resolve, reject){
|
||||
if(this.hasOwnProperty('error')){
|
||||
return this.constructor.reject(
|
||||
reject ?
|
||||
reject(this.error)
|
||||
: this.error) }
|
||||
if(this.hasOwnProperty('value')){
|
||||
return this.constructor.resolve(
|
||||
resolve(this.value)) } },
|
||||
return this.constructor.resolve(
|
||||
resolve(this.value)) },
|
||||
|
||||
// NOTE: if func calls resolve(..) with a promise then this will return
|
||||
// that promise...
|
||||
__new__: function(context, func){
|
||||
var result
|
||||
var resolve = function(res){
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user