All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.darylteo.rx.promises.groovy.Promise.groovy Maven / Gradle / Ivy

package com.darylteo.rx.promises.groovy

import com.darylteo.rx.promises.AbstractPromise
import rx.functions.Action0
import rx.functions.Func1

public class Promise extends AbstractPromise {
  public Promise() {
    super();
  }

  public Promise(rx.Observable source) {
    super(source);
  }

  public  Promise then(Map m = [:]) {
    return this.promise(m.onFulfilled, m.onRejected, null)
  }

  public  Promise then(Closure onFulfilled, Closure onRejected = null) {
    return this.promise(onFulfilled, onRejected, null);
  }

  public  Promise fail(Closure onRejected) {
    return this.promise(null, onRejected, null);
  }

  public  Promise fin(Closure onFinally) {
    return this.promise(null, null, onFinally);
  }

  private  Promise promise(Closure onFulfilled, Closure onRejected, Closure onFinally) {
    return (Promise) super._then(onFulfilled as Func1, onRejected as Func1, onFinally as Action0)
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy