JSNI Javascript promises

441 views
Skip to first unread message

Alex Ph

unread,
Jun 12, 2014, 8:38:34 AM6/12/14
to google-we...@googlegroups.com
Hi all,
I start to write a wrapper around a Javascript lib, where function calls are handled with promises, like get(bla).then(doThis,doThat).catch(stuff). If I try to wrap this function the gwt compiler "says" that I missed a name after . operator ... .catch(function...
After googling around I found out, that catch is a restricted keyword and I cannot use this inside the native block. Is it possible to escape the .catch(stuff) to get this work?

Thnx
Alex

Jens

unread,
Jun 12, 2014, 8:46:54 AM6/12/14
to google-we...@googlegroups.com
I have written a Promise library that uses native promises of the browser if possible and emulated promises otherwise. I had the same problem for native promises. I think it is forbidden to define a function with a name "catch" as it is a keyword however browsers have cheated on that in case of native promises.

In my case I could workaround it by using this["catch"](..) instead of this.catch(...). Maybe thats possible in your case too.


-- J.

Manuel Carrasco Moñino

unread,
Jun 12, 2014, 8:55:58 AM6/12/14
to Google-Web-Toolkit
Out of curiosity, have you guys tried gwt-query promises? they have the same syntax than jQuery ones, and work in browser and server sides.
You can see how them work in these slides: http://slides.gquery.org/gwtcreate/gwtcreate.html#18


--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-tool...@googlegroups.com.
To post to this group, send email to google-we...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

Jens

unread,
Jun 12, 2014, 9:38:28 AM6/12/14
to google-we...@googlegroups.com
Out of curiosity, have you guys tried gwt-query promises? they have the same syntax than jQuery ones, and work in browser and server sides.
You can see how them work in these slides: http://slides.gquery.org/gwtcreate/gwtcreate.html#18

I want something that can directly map to ES6 promises natively implemented in various browser (http://caniuse.com/promises) and uses a very similar API style as ES6 promises. Also I wanted more type safety in then().

-- J.

Peter Donald

unread,
Jun 12, 2014, 6:21:08 PM6/12/14
to google-we...@googlegroups.com
Out of curiosity, is this library open source or is it likely to be?
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-tool...@googlegroups.com.
To post to this group, send email to google-we...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.


--
Cheers,

Peter Donald

Jens

unread,
Jun 12, 2014, 6:43:52 PM6/12/14
to google-we...@googlegroups.com
Out of curiosity, is this library open source or is it likely to be?

It will soon be open source.

-- J.
Reply all
Reply to author
Forward
0 new messages