views:

90

answers:

2

I'm really interested in implementing Promises and related features in client-side Javascript. From what I've seen, the focus in implementing these technologies in Javascript seems to be on server-side javascript (SSJS) with Promises in CommonJS. Ideally for me, I would find a solution that works well with jQuery or Google Closure Library, but I'm open to any solution.

  • Is it possible to use the CommonJS solution client-side? This Sitepen article has some great information on promises in CommonJS, but it is focused on SSJS.
  • What other libraries are available that implement promises that can easily work client-side?
  • What are your impressions, experience, and feedback on any toolkit you have used?

I've found a few client-side implementations, but I'm unclear on how robust they are. Is there any library that has become the de-facto standard? Is a mainstream library (like jquery) already working on something similar for a future release?

Any others? Anyone have experience with any of these and have a preference? Is one better than the others?

+3  A: 

I'm the developer of FutureJS.

I started with the snippets from Crockford's slides. In fact, here's the original & unadultered implementation.

Now both parts of that blog post are part of the FuturesJS Documentation and there's more to come.

I'm very willing to modify FuturesJS to fit CommonJS if and when they have an official standard. I'd love to have you join the mailing list and give me your feedback and suggestions.

While I'm plugging, I'd also like to add that the aim of FuturesJS is to become the Async Toolbox of JavaScript. I also have subscriptions, triggers, synchronizations. As I run into more organizational issues and see what others have done I'll continue to update the library with best-practice solutions.

=8^D

P.S. FuturesJS will work alongside jQuery, Dojo, etc without issue. There are no dependencies. Also, I believe that it will work with Node.js and Rhino. If not, let me know and it should be a quick fix.

CoolAJ86
+2  A: 

http://www.sitepen.com/blog/2010/05/03/robust-promises-with-dojo-deferred-1-5/ should answer your question exactly

Dylan
@Dylan: Interesting. The other sitepen article I referenced suggests that Dojo Deferreds have flaws. Maybe it was in reference to an earlier version. However, the issue for me is that it is part of Dojo, and my application is heavily based on jQuery. I don't want to include all of Dojo as well, but if there is a way to just import the Deferred functionality, that could work.
Tauren