funcool

A channel for discussing and asking questions about Funcool libraries https://github.com/funcool/
jfntn 2015-11-05T17:14:22.000002Z

Hi @niwinz, I was looking for a portable promises abstraction and found your promesa and promissum libraries.

jfntn 2015-11-05T17:14:48.000003Z

Was wondering if you’d considered bridging the gap and provide some kind of portable interface?

niwinz 2015-11-05T17:15:15.000004Z

Hi @jfntn they are "almost" portable

niwinz 2015-11-05T17:15:35.000005Z

I mean that the differences between the two promises are just becuase of platform differences

niwinz 2015-11-05T17:16:27.000006Z

promesa (cljs) can't do blocking calls because them are imposible in js...

jfntn 2015-11-05T17:16:45.000007Z

sur ebut with cljc they could be packaged together now under the same api

niwinz 2015-11-05T17:17:47.000008Z

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...

jfntn 2015-11-05T17:18:14.000009Z

oh I missed that

niwinz 2015-11-05T17:18:25.000010Z

They are packaged separatedly because promissum requires jdk8

niwinz 2015-11-05T17:18:32.000011Z

but promesa not requires it

niwinz 2015-11-05T17:19:46.000012Z

Maybe is possible package them in one unique library, but at this moment I don't know if that a proper way...

jfntn 2015-11-05T17:20:56.000013Z

yeah I wonder if you could set up your maven deps so that the cljs part wouldn’t require jdk8

niwinz 2015-11-05T17:22:27.000014Z

Hmm, I will think about, maybe you are right and package them together seems a good idea

jfntn 2015-11-05T17:26:29.000016Z

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

niwinz 2015-11-05T17:27:21.000017Z

in clojure/jdk impl

niwinz 2015-11-05T17:27:36.000018Z

an error can be only an instance of Exception/Throwable

niwinz 2015-11-05T17:27:43.000019Z

but in cljs/js can be any object

jfntn 2015-11-05T17:27:52.000020Z

oh I didn’t know that 😛

jfntn 2015-11-05T17:28:09.000021Z

so you can throw anything in cljs?

niwinz 2015-11-05T17:28:17.000022Z

Yes xD

jfntn 2015-11-05T17:28:28.000023Z

hmm, wouldn’t you be able to catch it though?

niwinz 2015-11-05T17:29:09.000024Z

yes, js is dynamic lang and you can't specify the type in catch block

niwinz 2015-11-05T17:30:04.000025Z

because of that, in cljs promise constructor receives two callbacks

niwinz 2015-11-05T17:30:10.000026Z

one for resolve and other for reject

niwinz 2015-11-05T17:30:47.000027Z

because it there isnt' any way to distinguish if an value is an error or an valid value

niwinz 2015-11-05T17:31:03.000028Z

in clj/jdk this not happens

niwinz 2015-11-05T17:31:15.000029Z

and the resolve function is fully polymorphic

niwinz 2015-11-05T17:33:44.000031Z

In any case I'm pretty convinced now that differences can be handled properly in one unique package

niwinz 2015-11-05T17:34:04.000032Z

so I surely start working in joining them

jfntn 2015-11-05T17:34:39.000033Z

Yeah I’m still not sure why you wouldn’t be able to catch any object getting thrown in a promise’s fn ctor

jfntn 2015-11-05T17:35:37.000034Z

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 😉

niwinz 2015-11-05T17:36:54.000035Z

Nice!