Hi @niwinz, I was looking for a portable promises abstraction and found your promesa and promissum libraries.
Was wondering if you’d considered bridging the gap and provide some kind of portable interface?
Hi @jfntn they are "almost" portable
I mean that the differences between the two promises are just becuase of platform differences
promesa (cljs) can't do blocking calls because them are imposible in js...
sur ebut with cljc they could be packaged together now under the same api
and the promise constructor differes a little bit because in cljs/js an error can be anything so is no way to distinguish between values, because of this the cljs constructor receives 2 callbacks and the clj one...
oh I missed that
They are packaged separatedly because promissum requires jdk8
but promesa not requires it
Maybe is possible package them in one unique library, but at this moment I don't know if that a proper way...
yeah I wonder if you could set up your maven deps so that the cljs part wouldn’t require jdk8
Hmm, I will think about, maybe you are right and package them together seems a good idea
Cool, could you elaborate a little bit on the difference in error handling that requires different promise constructors? I’m not sure I understand why this is necessary
in clojure/jdk impl
an error can be only an instance of Exception/Throwable
but in cljs/js can be any object
oh I didn’t know that 😛
so you can throw anything in cljs?
Yes xD
hmm, wouldn’t you be able to catch it though?
yes, js is dynamic lang and you can't specify the type in catch block
because of that, in cljs promise constructor receives two callbacks
one for resolve and other for reject
because it there isnt' any way to distinguish if an value is an error or an valid value
in clj/jdk this not happens
and the resolve function is fully polymorphic
In any case I'm pretty convinced now that differences can be handled properly in one unique package
so I surely start working in joining them
Yeah I’m still not sure why you wouldn’t be able to catch any object getting thrown in a promise’s fn ctor
Ok cool, I’m sure this will be really helpful, I’ve been working on a protable ring-cps http client and don’t want to add promises to the middleware stack, but they would be really useful as adapters 😉
Nice!