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

elemental2.dom.FetchEvent Maven / Gradle / Ivy

There is a newer version: 1.0.139
Show newest version
package elemental2.dom;

import elemental2.promise.IThenable;
import elemental2.promise.Promise;
import jsinterop.annotations.JsMethod;
import jsinterop.annotations.JsOverlay;
import jsinterop.annotations.JsPackage;
import jsinterop.annotations.JsType;
import jsinterop.base.Js;

@JsType(isNative = true, namespace = JsPackage.GLOBAL)
public class FetchEvent extends ExtendableEvent {
  @JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL)
  public interface RespondWithRUnionType {
    @JsOverlay
    static FetchEvent.RespondWithRUnionType of(Object o) {
      return Js.cast(o);
    }

    @JsOverlay
    default IThenable asIThenable() {
      return Js.cast(this);
    }

    @JsOverlay
    default Response asResponse() {
      return Js.cast(this);
    }

    @JsOverlay
    default boolean isResponse() {
      return (Object) this instanceof Response;
    }
  }

  public ServiceWorkerClient client;
  public String clientId;
  public boolean isReload;
  public Promise preloadResponse;
  public Request request;
  public String reservedClientId;
  public String targetClientId;

  public FetchEvent(String type, FetchEventInit eventInitDict) {
    // This call is only here for java compilation purpose.
    super((String) null, (ExtendableEventInit) null);
  }

  public FetchEvent(String type) {
    // This call is only here for java compilation purpose.
    super((String) null, (ExtendableEventInit) null);
  }

  @JsMethod(name = "default")
  public native Promise default_();

  public native Promise forwardTo(String url);

  @JsOverlay
  public final void respondWith(IThenable r) {
    respondWith(Js.uncheckedCast(r));
  }

  public native void respondWith(FetchEvent.RespondWithRUnionType r);

  @JsOverlay
  public final void respondWith(Response r) {
    respondWith(Js.uncheckedCast(r));
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy