jdonaldson / promhx

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

Detect Thenable? #76

Closed indolering closed 8 years ago

indolering commented 8 years ago

I'm using Haxe to perform a validation pass on data before sending it back to the server. So my Haxe library is totally synchronous but it's sandwiched in-between a bunch of asynchronous code. I also use the library on the server to check data as it comes in and that code is all synchronous. I'd like to be able to (at least in JavaScript) offer both a synchronous and promise based interface.

Advice? Can I detect whether the caller has attached a then/catch function at runtime?

jdonaldson commented 8 years ago

Sorry for the late delay on this, I looked into it and got sidetracked.

You may want to try a different approach if you need to mix synchronous/asynchronous style coding.

For instance, there's projects that abstract away callbacks into return values: https://github.com/Atry/haxe-continuation https://github.com/stroncium/hx-async