Hi!
Would be nice if igniteFuture would provide a small but very usable method: public <R> R to(Function<IgniteFuture<T>, R> transformer) it will allow to chain it like: compute.runAsync(runnable).to(rx()).timeout(5_000).subscribe() Where rx() is just a static function with something like: public static <T> Function<IgniteFuture<T>, Observable<T>> rx() WDYT? |
IgniteFuture have method
public <T> IgniteFuture<T> chain(IgniteClosure<? super IgniteFuture<V>, T> doneCb); which do this. 2017-03-27 13:30 GMT+03:00 Sergei Egorov <[hidden email]>: > Hi! > > Would be nice if igniteFuture would provide a small but very usable method: > > public <R> R to(Function<IgniteFuture<T>, R> transformer) > > it will allow to chain it like: > > compute.runAsync(runnable).to(rx()).timeout(5_000).subscribe() > > Where rx() is just a static function with something like: > > public static <T> Function<IgniteFuture<T>, Observable<T>> rx() > > > WDYT? > 2017-03-27 13:30 GMT+03:00 Sergei Egorov <[hidden email]>: > Hi! > > Would be nice if igniteFuture would provide a small but very usable method: > > public <R> R to(Function<IgniteFuture<T>, R> transformer) > > it will allow to chain it like: > > compute.runAsync(runnable).to(rx()).timeout(5_000).subscribe() > > Where rx() is just a static function with something like: > > public static <T> Function<IgniteFuture<T>, Observable<T>> rx() > > > WDYT? > |
It doesn't :)
It returns another IgniteFuture where I want to transform it to completely different type. On Mon, Mar 27, 2017 at 1:41 PM Дмитрий Рябов <[hidden email]> wrote: > IgniteFuture have method > > public <T> IgniteFuture<T> chain(IgniteClosure<? super IgniteFuture<V>, T> > doneCb); > > which do this. > > 2017-03-27 13:30 GMT+03:00 Sergei Egorov <[hidden email]>: > > > Hi! > > > > Would be nice if igniteFuture would provide a small but very usable > method: > > > > public <R> R to(Function<IgniteFuture<T>, R> transformer) > > > > it will allow to chain it like: > > > > compute.runAsync(runnable).to(rx()).timeout(5_000).subscribe() > > > > Where rx() is just a static function with something like: > > > > public static <T> Function<IgniteFuture<T>, Observable<T>> rx() > > > > > > WDYT? > > > > > 2017-03-27 13:30 GMT+03:00 Sergei Egorov <[hidden email]>: > > > Hi! > > > > Would be nice if igniteFuture would provide a small but very usable > method: > > > > public <R> R to(Function<IgniteFuture<T>, R> transformer) > > > > it will allow to chain it like: > > > > compute.runAsync(runnable).to(rx()).timeout(5_000).subscribe() > > > > Where rx() is just a static function with something like: > > > > public static <T> Function<IgniteFuture<T>, Observable<T>> rx() > > > > > > WDYT? > > > |
Em... When you get result of your future, closure will produce new future
with completely different type. 2017-03-27 13:43 GMT+03:00 Sergei Egorov <[hidden email]>: > It doesn't :) > > It returns another IgniteFuture where I want to transform it to completely > different type. > > On Mon, Mar 27, 2017 at 1:41 PM Дмитрий Рябов <[hidden email]> > wrote: > > > IgniteFuture have method > > > > public <T> IgniteFuture<T> chain(IgniteClosure<? super IgniteFuture<V>, > T> > > doneCb); > > > > which do this. > > > > 2017-03-27 13:30 GMT+03:00 Sergei Egorov <[hidden email]>: > > > > > Hi! > > > > > > Would be nice if igniteFuture would provide a small but very usable > > method: > > > > > > public <R> R to(Function<IgniteFuture<T>, R> transformer) > > > > > > it will allow to chain it like: > > > > > > compute.runAsync(runnable).to(rx()).timeout(5_000).subscribe() > > > > > > Where rx() is just a static function with something like: > > > > > > public static <T> Function<IgniteFuture<T>, Observable<T>> rx() > > > > > > > > > WDYT? > > > > > > > > > 2017-03-27 13:30 GMT+03:00 Sergei Egorov <[hidden email]>: > > > > > Hi! > > > > > > Would be nice if igniteFuture would provide a small but very usable > > method: > > > > > > public <R> R to(Function<IgniteFuture<T>, R> transformer) > > > > > > it will allow to chain it like: > > > > > > compute.runAsync(runnable).to(rx()).timeout(5_000).subscribe() > > > > > > Where rx() is just a static function with something like: > > > > > > public static <T> Function<IgniteFuture<T>, Observable<T>> rx() > > > > > > > > > WDYT? > > > > > > |
Take a look at my initial code.
public <T> IgniteFuture<T> chain(IgniteClosure<? super IgniteFuture<V>, T> doneCb); vs public <R> R to(IgniteClosure<? super IgniteFuture<V>, R> transformer); The result of "chain" is IgniteFuture. The result of "to" is the object returned from transformer. It would be CompletableFuture, Rx's Observable, Reactor's Mono, etc... On Mon, Mar 27, 2017 at 3:18 PM Дмитрий Рябов <[hidden email]> wrote: > Em... When you get result of your future, closure will produce new future > with completely different type. > > 2017-03-27 13:43 GMT+03:00 Sergei Egorov <[hidden email]>: > > > It doesn't :) > > > > It returns another IgniteFuture where I want to transform it to > completely > > different type. > > > > On Mon, Mar 27, 2017 at 1:41 PM Дмитрий Рябов <[hidden email]> > > wrote: > > > > > IgniteFuture have method > > > > > > public <T> IgniteFuture<T> chain(IgniteClosure<? super IgniteFuture<V>, > > T> > > > doneCb); > > > > > > which do this. > > > > > > 2017-03-27 13:30 GMT+03:00 Sergei Egorov <[hidden email]>: > > > > > > > Hi! > > > > > > > > Would be nice if igniteFuture would provide a small but very usable > > > method: > > > > > > > > public <R> R to(Function<IgniteFuture<T>, R> transformer) > > > > > > > > it will allow to chain it like: > > > > > > > > compute.runAsync(runnable).to(rx()).timeout(5_000).subscribe() > > > > > > > > Where rx() is just a static function with something like: > > > > > > > > public static <T> Function<IgniteFuture<T>, Observable<T>> rx() > > > > > > > > > > > > WDYT? > > > > > > > > > > > > > 2017-03-27 13:30 GMT+03:00 Sergei Egorov <[hidden email]>: > > > > > > > Hi! > > > > > > > > Would be nice if igniteFuture would provide a small but very usable > > > method: > > > > > > > > public <R> R to(Function<IgniteFuture<T>, R> transformer) > > > > > > > > it will allow to chain it like: > > > > > > > > compute.runAsync(runnable).to(rx()).timeout(5_000).subscribe() > > > > > > > > Where rx() is just a static function with something like: > > > > > > > > public static <T> Function<IgniteFuture<T>, Observable<T>> rx() > > > > > > > > > > > > WDYT? > > > > > > > > > > |
Sergei,
Why should this method be a part of the future API? The only implementation will do "return func(this);" I can achieve the same result the following way: rx(compute.runAsync(runnable)).timeout(5_000).subscribe(); 2017-03-27 15:54 GMT+03:00 Sergei Egorov <[hidden email]>: > Take a look at my initial code. > > public <T> IgniteFuture<T> chain(IgniteClosure<? super > IgniteFuture<V>, T> doneCb); > > vs > > public <R> R to(IgniteClosure<? super IgniteFuture<V>, R> transformer); > > > The result of "chain" is IgniteFuture. > > The result of "to" is the object returned from transformer. It would > be CompletableFuture, Rx's Observable, Reactor's Mono, etc... > > > On Mon, Mar 27, 2017 at 3:18 PM Дмитрий Рябов <[hidden email]> > wrote: > > > Em... When you get result of your future, closure will produce new future > > with completely different type. > > > > 2017-03-27 13:43 GMT+03:00 Sergei Egorov <[hidden email]>: > > > > > It doesn't :) > > > > > > It returns another IgniteFuture where I want to transform it to > > completely > > > different type. > > > > > > On Mon, Mar 27, 2017 at 1:41 PM Дмитрий Рябов <[hidden email]> > > > wrote: > > > > > > > IgniteFuture have method > > > > > > > > public <T> IgniteFuture<T> chain(IgniteClosure<? super > IgniteFuture<V>, > > > T> > > > > doneCb); > > > > > > > > which do this. > > > > > > > > 2017-03-27 13:30 GMT+03:00 Sergei Egorov <[hidden email]>: > > > > > > > > > Hi! > > > > > > > > > > Would be nice if igniteFuture would provide a small but very usable > > > > method: > > > > > > > > > > public <R> R to(Function<IgniteFuture<T>, R> transformer) > > > > > > > > > > it will allow to chain it like: > > > > > > > > > > compute.runAsync(runnable).to(rx()).timeout(5_000).subscribe() > > > > > > > > > > Where rx() is just a static function with something like: > > > > > > > > > > public static <T> Function<IgniteFuture<T>, Observable<T>> rx() > > > > > > > > > > > > > > > WDYT? > > > > > > > > > > > > > > > > > 2017-03-27 13:30 GMT+03:00 Sergei Egorov <[hidden email]>: > > > > > > > > > Hi! > > > > > > > > > > Would be nice if igniteFuture would provide a small but very usable > > > > method: > > > > > > > > > > public <R> R to(Function<IgniteFuture<T>, R> transformer) > > > > > > > > > > it will allow to chain it like: > > > > > > > > > > compute.runAsync(runnable).to(rx()).timeout(5_000).subscribe() > > > > > > > > > > Where rx() is just a static function with something like: > > > > > > > > > > public static <T> Function<IgniteFuture<T>, Observable<T>> rx() > > > > > > > > > > > > > > > WDYT? > > > > > > > > > > > > > > > |
+1 to Alex, this is something external to IgniteFuture.
Should Ignite was implemented in .NET, we could have add proposed feature it using extension methods. But (un)fortunately Ignite is Java-based :-) On Mon, Mar 27, 2017 at 4:06 PM, Alexey Goncharuk < [hidden email]> wrote: > Sergei, > > Why should this method be a part of the future API? The only implementation > will do "return func(this);" > > I can achieve the same result the following way: > rx(compute.runAsync(runnable)).timeout(5_000).subscribe(); > > > > 2017-03-27 15:54 GMT+03:00 Sergei Egorov <[hidden email]>: > > > Take a look at my initial code. > > > > public <T> IgniteFuture<T> chain(IgniteClosure<? super > > IgniteFuture<V>, T> doneCb); > > > > vs > > > > public <R> R to(IgniteClosure<? super IgniteFuture<V>, R> transformer); > > > > > > The result of "chain" is IgniteFuture. > > > > The result of "to" is the object returned from transformer. It would > > be CompletableFuture, Rx's Observable, Reactor's Mono, etc... > > > > > > On Mon, Mar 27, 2017 at 3:18 PM Дмитрий Рябов <[hidden email]> > > wrote: > > > > > Em... When you get result of your future, closure will produce new > future > > > with completely different type. > > > > > > 2017-03-27 13:43 GMT+03:00 Sergei Egorov <[hidden email]>: > > > > > > > It doesn't :) > > > > > > > > It returns another IgniteFuture where I want to transform it to > > > completely > > > > different type. > > > > > > > > On Mon, Mar 27, 2017 at 1:41 PM Дмитрий Рябов <[hidden email] > > > > > > wrote: > > > > > > > > > IgniteFuture have method > > > > > > > > > > public <T> IgniteFuture<T> chain(IgniteClosure<? super > > IgniteFuture<V>, > > > > T> > > > > > doneCb); > > > > > > > > > > which do this. > > > > > > > > > > 2017-03-27 13:30 GMT+03:00 Sergei Egorov <[hidden email]>: > > > > > > > > > > > Hi! > > > > > > > > > > > > Would be nice if igniteFuture would provide a small but very > usable > > > > > method: > > > > > > > > > > > > public <R> R to(Function<IgniteFuture<T>, R> transformer) > > > > > > > > > > > > it will allow to chain it like: > > > > > > > > > > > > compute.runAsync(runnable).to(rx()).timeout(5_000). > subscribe() > > > > > > > > > > > > Where rx() is just a static function with something like: > > > > > > > > > > > > public static <T> Function<IgniteFuture<T>, Observable<T>> > rx() > > > > > > > > > > > > > > > > > > WDYT? > > > > > > > > > > > > > > > > > > > > > 2017-03-27 13:30 GMT+03:00 Sergei Egorov <[hidden email]>: > > > > > > > > > > > Hi! > > > > > > > > > > > > Would be nice if igniteFuture would provide a small but very > usable > > > > > method: > > > > > > > > > > > > public <R> R to(Function<IgniteFuture<T>, R> transformer) > > > > > > > > > > > > it will allow to chain it like: > > > > > > > > > > > > compute.runAsync(runnable).to(rx()).timeout(5_000). > subscribe() > > > > > > > > > > > > Where rx() is just a static function with something like: > > > > > > > > > > > > public static <T> Function<IgniteFuture<T>, Observable<T>> > rx() > > > > > > > > > > > > > > > > > > WDYT? > > > > > > > > > > > > > > > > > > > > > |
In reply to this post by Alexey Goncharuk
True, I just prefer functional style over static methods.
Regarding "why should this method be a part of the future API" - why not? It helps to chain such calls instead of call nesting. Of course, if Java had extension methods it wouldn't be needed, but we don't have them. On Mon, Mar 27, 2017 at 4:06 PM Alexey Goncharuk <[hidden email]> wrote: > Sergei, > > Why should this method be a part of the future API? The only implementation > will do "return func(this);" > > I can achieve the same result the following way: > rx(compute.runAsync(runnable)).timeout(5_000).subscribe(); > > > > 2017-03-27 15:54 GMT+03:00 Sergei Egorov <[hidden email]>: > > > Take a look at my initial code. > > > > public <T> IgniteFuture<T> chain(IgniteClosure<? super > > IgniteFuture<V>, T> doneCb); > > > > vs > > > > public <R> R to(IgniteClosure<? super IgniteFuture<V>, R> transformer); > > > > > > The result of "chain" is IgniteFuture. > > > > The result of "to" is the object returned from transformer. It would > > be CompletableFuture, Rx's Observable, Reactor's Mono, etc... > > > > > > On Mon, Mar 27, 2017 at 3:18 PM Дмитрий Рябов <[hidden email]> > > wrote: > > > > > Em... When you get result of your future, closure will produce new > future > > > with completely different type. > > > > > > 2017-03-27 13:43 GMT+03:00 Sergei Egorov <[hidden email]>: > > > > > > > It doesn't :) > > > > > > > > It returns another IgniteFuture where I want to transform it to > > > completely > > > > different type. > > > > > > > > On Mon, Mar 27, 2017 at 1:41 PM Дмитрий Рябов <[hidden email] > > > > > > wrote: > > > > > > > > > IgniteFuture have method > > > > > > > > > > public <T> IgniteFuture<T> chain(IgniteClosure<? super > > IgniteFuture<V>, > > > > T> > > > > > doneCb); > > > > > > > > > > which do this. > > > > > > > > > > 2017-03-27 13:30 GMT+03:00 Sergei Egorov <[hidden email]>: > > > > > > > > > > > Hi! > > > > > > > > > > > > Would be nice if igniteFuture would provide a small but very > usable > > > > > method: > > > > > > > > > > > > public <R> R to(Function<IgniteFuture<T>, R> transformer) > > > > > > > > > > > > it will allow to chain it like: > > > > > > > > > > > > > compute.runAsync(runnable).to(rx()).timeout(5_000).subscribe() > > > > > > > > > > > > Where rx() is just a static function with something like: > > > > > > > > > > > > public static <T> Function<IgniteFuture<T>, Observable<T>> > rx() > > > > > > > > > > > > > > > > > > WDYT? > > > > > > > > > > > > > > > > > > > > > 2017-03-27 13:30 GMT+03:00 Sergei Egorov <[hidden email]>: > > > > > > > > > > > Hi! > > > > > > > > > > > > Would be nice if igniteFuture would provide a small but very > usable > > > > > method: > > > > > > > > > > > > public <R> R to(Function<IgniteFuture<T>, R> transformer) > > > > > > > > > > > > it will allow to chain it like: > > > > > > > > > > > > > compute.runAsync(runnable).to(rx()).timeout(5_000).subscribe() > > > > > > > > > > > > Where rx() is just a static function with something like: > > > > > > > > > > > > public static <T> Function<IgniteFuture<T>, Observable<T>> > rx() > > > > > > > > > > > > > > > > > > WDYT? > > > > > > > > > > > > > > > > > > > > > |
Free forum by Nabble | Edit this page |