Class Promises


  • @Dependent
    public class Promises
    extends Object
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Promises.Error<T>  
    • Constructor Summary

      Constructors 
      Constructor Description
      Promises()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <O> elemental2.promise.Promise<O> all​(elemental2.promise.Promise<O>... promises)
      Returns a resolved Promise when every Promise in the list is resolved.
      <T,​O>
      elemental2.promise.Promise<O>
      all​(List<T> objects, Function<T,​elemental2.promise.Promise<O>> f)
      Maps the objects to Promises using the provided function then behaves just like all(elemental2.promise.Promise<O>...).
      <V,​T>
      elemental2.promise.Promise<T>
      catchOrExecute​(Object o, Function<RuntimeException,​elemental2.promise.Promise<T>> catchBlock, Function<V,​elemental2.promise.Promise<T>> expectedRejectionHandler)
      To be used inside Promise.catch_(elemental2.promise.Promise.CatchOnRejectedCallbackFn<? extends V>) blocks.
      <T> elemental2.promise.Promise<T> create​(elemental2.promise.Promise.PromiseExecutorCallbackFn<T> executor)  
      void init()  
      <T,​S>
      elemental2.promise.Promise<S>
      promisify​(org.jboss.errai.common.client.api.Caller<T> caller, Consumer<T> call)
      Promisifies a Caller remote call.
      <T,​S>
      elemental2.promise.Promise<S>
      promisify​(org.jboss.errai.common.client.api.Caller<T> caller, Function<T,​S> call)
      Promisifies a Caller remote call.
      <O> elemental2.promise.Promise<O> reduce​(elemental2.promise.Promise<O> identity, Collection<elemental2.promise.Promise<O>> promises, BinaryOperator<elemental2.promise.Promise<O>> accumulator)
      Reduces a list of promises using the accumulator passed.
      <T,​O>
      elemental2.promise.Promise<O>
      reduceLazily​(List<T> objects, Function<T,​elemental2.promise.Promise<O>> f)
      Maps the objects to Promises using the provided function but only execute the Promises when the previous Promise is resolved.
      <T,​O>
      elemental2.promise.Promise<O>
      reduceLazilyChaining​(List<T> objects, BiFunction<Supplier<elemental2.promise.Promise<O>>,​T,​elemental2.promise.Promise<O>> f)
      Behaves just like reduceLazily(java.util.List<T>, java.util.function.Function<T, elemental2.promise.Promise<O>>) but exposes a reference to the Promise chain as a parameter to the mapping function.
      <T> elemental2.promise.Promise<T> reject​(Object object)  
      <T> elemental2.promise.Promise<T> resolve()  
      <T> elemental2.promise.Promise<T> resolve​(T object)  
    • Constructor Detail

      • Promises

        public Promises()
    • Method Detail

      • all

        @SafeVarargs
        public final <O> elemental2.promise.Promise<O> all​(elemental2.promise.Promise<O>... promises)
        Returns a resolved Promise when every Promise in the list is resolved. If any Promise is rejected, the resulting Promise will be rejected.
      • all

        public <T,​O> elemental2.promise.Promise<O> all​(List<T> objects,
                                                             Function<T,​elemental2.promise.Promise<O>> f)
        Maps the objects to Promises using the provided function then behaves just like all(elemental2.promise.Promise<O>...).
      • reduce

        public final <O> elemental2.promise.Promise<O> reduce​(elemental2.promise.Promise<O> identity,
                                                              Collection<elemental2.promise.Promise<O>> promises,
                                                              BinaryOperator<elemental2.promise.Promise<O>> accumulator)
        Reduces a list of promises using the accumulator passed.
      • reduceLazily

        public <T,​O> elemental2.promise.Promise<O> reduceLazily​(List<T> objects,
                                                                      Function<T,​elemental2.promise.Promise<O>> f)
        Maps the objects to Promises using the provided function but only execute the Promises when the previous Promise is resolved. If a rejection occurs in the middle of the chain, the remaining Promises are not executed and the resulting Promise is rejected.
      • promisify

        public <T,​S> elemental2.promise.Promise<S> promisify​(org.jboss.errai.common.client.api.Caller<T> caller,
                                                                   Function<T,​S> call)
        Promisifies a Caller remote call. If an exception is thrown inside the call function, the resulting Promise is rejected with a Promises.Error instance.
      • promisify

        public <T,​S> elemental2.promise.Promise<S> promisify​(org.jboss.errai.common.client.api.Caller<T> caller,
                                                                   Consumer<T> call)
        Promisifies a Caller remote call. If an exception is thrown inside the call function, the resulting Promise is rejected with a Promises.Error instance.
      • catchOrExecute

        public <V,​T> elemental2.promise.Promise<T> catchOrExecute​(Object o,
                                                                        Function<RuntimeException,​elemental2.promise.Promise<T>> catchBlock,
                                                                        Function<V,​elemental2.promise.Promise<T>> expectedRejectionHandler)
        To be used inside Promise.catch_(elemental2.promise.Promise.CatchOnRejectedCallbackFn<? extends V>) blocks. Decides whether to process a RuntimeException that caused a prior Promise rejection or to process an expected object rejected by a prior Promise. To proceed with default error handlers, reject the untreated exception inside the catchBlock function.
      • resolve

        public <T> elemental2.promise.Promise<T> resolve()
      • resolve

        public <T> elemental2.promise.Promise<T> resolve​(T object)
      • reject

        public <T> elemental2.promise.Promise<T> reject​(Object object)
      • create

        public <T> elemental2.promise.Promise<T> create​(elemental2.promise.Promise.PromiseExecutorCallbackFn<T> executor)