jdonaldson / promhx

A promise and functional reactive programming library for Haxe
MIT License
145 stars 24 forks source link

Promise.when and function that returns promise #61

Closed modjke closed 9 years ago

modjke commented 9 years ago

Consider the following scenario (usable when implementing remote service calls)

function request():Promise<String>  
{
    var def = new Deferred<String>();
    def.resolve("response");
    return def.promise();
}

Now you want to make more than one request at once

Promise.when(request(), request()).then(function (r1, r2)
{
//both r1 and r2 will be null here
});

I've already pinned down an issue with your macro, going to submit a pull-request for that one

modjke commented 9 years ago

Also, Stream.when has exactly the same problem

modjke commented 9 years ago

Pull is up https://github.com/jdonaldson/promhx/pull/62