@adamfrey many of the cats facilities for work with promises is already in a separated library: funcool/promesa, and the latest version inclused support for other thenables than bluebird, so probably you can use it with jquery promise abstraction
I’ve been in the Promesa library code, but I didn’t realize that there was support for other promise types. Added 2 days ago at that. just in time! Thanks!
@niwinz With the new version of Promesa I can use promesa.core/then
with a jQuery deferred object just like you said. But when I try to use one in a cats.core/alet
macro, I get a “No context is set…" error
sure
https://github.com/funcool/cats/blob/master/src/cats/labs/promise.cljc#L13
you should extend the jquery deferred type
with some cats related protocols in the same way as we do it with bluebird promise object
ok, that’s what I originally thought. But I was mistaken just now in thinking that cats would recognize a jQuery deferred object as some sort of generic promise. Thanks for your help
there are no magic, cats works with types and protocols if some type does not implements its protocols, it will not work with them
I think opening Promesa to other promise implementations is really cool, I played with wrapping Closure :closurelib: promises but didn't get very far. Are you aware of implementations other than the default one based on Bluebird using the promesa protocols? @niwinz
@martinklepsch I'm not aware of
the latest version of promesa supports the usage of other promise types with promesa abstractions
in fact, it support anything "thenable" in promises vocabulary
My main concern in replacing bluebird promise is the perfomance and the introspection
among the debugging stuff such that long stack traces that bluebird has...
Yeah, I'm by no means suggesting bluebird should be replaced, I'm sure there are good reasons that Promesa is build on top of it 🙂 I just think it'd be nice to also have a version of the library that does 80% without the bluebird dependency (using goog.Promise which is probably included in your build anyways).
hmm is not bad idea but I don't know how we can do it in one unique library
doesn't have to be the same lib, could be promesa-closure or whatever which depends on promesa but excludes the bluebird dep or similar
Either way I think this is fine for other people to do that want it (like me) and probably not something you should officially support/implement
I'd just like to have some kind of reference impl that I can use as a base/helps me understand what exactly needs to be done, but maybe @adamfrey makes something on the jQuery promise stuff and that will be just fine 🙂
I agree with you
but in some manner I want to have a more lightweight impl for promesa
bluebird is good in one aspect but no so good in other
the size of the library