jdonaldson / promhx

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

Make Thenable an interface (not typedef) for more efficient compile time type checking and possibly better perfomance on static platforms #60

Closed modjke closed 9 years ago

modjke commented 9 years ago

Hey, it is me again, after some AsyncBase changes Thenable typedef was broken once again, so i decided to make it an 'read only' interface for promises and streams. Since AsyncBase now implements Thenable you can do stuff like that

public function remoteRequest():Thenable<String>
{
    var def = new Deferred<String>();
    def.resolve( "yay" );
    return def.promise();
}

remoteRequest().then(function(str)
{
    trace(str);
});
modjke commented 9 years ago

Ok, now i get it, AsyncBase must be used in that case... can't see any purpose in Thenable typedef then.

jdonaldson commented 9 years ago

There's been some changes in haxe 3.2 that might make this possible, I just need to rework things. I've got a number of other pending changes in the works for a version 2.0. It should be backwards compatible provided you're on haxe 3.2. So, stay tuned.