ArcBees / gwtquery

A jQuery clone for GWT, and much more.
MIT License
85 stars 38 forks source link

Type safe promises prototype #301

Closed ibaca closed 9 years ago

ibaca commented 9 years ago

Discussion https://groups.google.com/forum/#!topic/gwtquery/mMey1XVkNGM

I don't add types for failures and progress because I prefer a simpler solution. Also, I propose the Zip strategy (https://github.com/ReactiveX/RxJava/blob/1.x/src/main/java/rx/Observable.java#L2639) because it's solves the problem whitout add complex generics in Promise interface.

Related project https://github.com/jdeferred/jdeferred, this project is an example of full typesafe promises. Although I think that add the failure type as generic is a bad idea (unnecessary complexity), I vote for failures to be Thorwables (reactivex strategy).

Review on Reviewable

jDramaix commented 9 years ago

Thanks for the contribution and sorry for the delay. I let Manolo handle this PR

manolo commented 9 years ago

@ibaca I have a meeting with @jDramaix next week, I guess we can talk about this patch. Basically I want to talk in a more general way how to deal with Function in gQuery and prepare it to use j8 lambdas, this patch definitively is a good reference.

jDramaix commented 9 years ago

@manolo I think we can close this ?

@ibaca The idea is to prepare Function in order to be able to use java 8 lambda instead.

ibaca commented 9 years ago

Ok, one final thought :wink: (I see this the other day, I want to leave the link here) and you can close it.

This tuple strategy https://github.com/reactor/reactor/wiki/Tuples might be interesting, so the Deferred and Promise can be implemented of one type T, and the current Function.argument(N) methdods might be implemented as a extension of TupleN with the auto-cast mehtod argument(N). Ex:

class Arguments extends TupleN {
  public <T> T argument(int index) { return (T) get(index); }
}
// so all current internal gwtquery promises usages will looks like
Promise<Arguments> promise = ...
manolo commented 9 years ago

@ibaca, as Julien says we want function interfaces in all places where Function is used, not only in promises, could we take this code as base? are you interested on contributing? If you have a while we could have a meeting, I guess you are in Spain as me so we can speak Spanish :-)

ibaca commented 9 years ago

@manolo, you can use this as a code base, although be careful with Functions that is almost copied from rxjava. You probably need to prototype other strategies so probably Functions is not needed finally. I'm interested in contributing, but I cannot compromise. I have some difficulties with English :open_mouth:, so meetings in Spanish are always welcome. I'm also in the irc #GWT channel.

olafleur commented 9 years ago

Last commit was more than 6 months ago. Closing. Feel free to reopen a pull request as needed.