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

js.web.indexeddb.IDBTransaction Maven / Gradle / Ivy

package js.web.indexeddb;


import js.web.dom.*;
import org.teavm.jso.JSBody;
import org.teavm.jso.JSProperty;

import javax.annotation.Nullable;

/**
 * Created by Artem Godin on 1/22/2020.
 */
public interface IDBTransaction extends EventTarget {
    @JSBody(script = "return IDBTransaction.prototype")
    static IDBTransaction prototype() {
        throw new UnsupportedOperationException("Available only in JavaScript");
    }

    @JSBody(script = "return new IDBTransaction()")
    static IDBTransaction create() {
        throw new UnsupportedOperationException("Available only in JavaScript");
    }

    /**
     * Returns the transaction's connection.
     */
    @JSProperty
    IDBDatabase getDb();

    /**
     * If the transaction was aborted, returns the error (a DOMException) providing the reason.
     */
    @JSProperty
    DOMException getError();

    /**
     * Returns the mode the transaction was created with ("readonly" or "readwrite"), or "versionchange" for an upgrade transaction.
     */
    @JSProperty
    IDBTransactionMode getMode();

    /**
     * Returns a list of the names of object stores in the transaction's scope. For an upgrade transaction this is all object stores in the database.
     */
    @JSProperty
    DOMStringList getObjectStoreNames();

    @JSProperty
    @Nullable
    EventListener getOnabort();

    @JSProperty
    void setOnabort(EventListener onabort);

    default void addAbortEventListener(EventListener listener, AddEventListenerOptions options) {
        addEventListener("abort", listener, options);
    }

    default void addAbortEventListener(EventListener listener, boolean options) {
        addEventListener("abort", listener, options);
    }

    default void addAbortEventListener(EventListener listener) {
        addEventListener("abort", listener);
    }

    default void removeAbortEventListener(EventListener listener, EventListenerOptions options) {
        removeEventListener("abort", listener, options);
    }

    default void removeAbortEventListener(EventListener listener, boolean options) {
        removeEventListener("abort", listener, options);
    }

    default void removeAbortEventListener(EventListener listener) {
        removeEventListener("abort", listener);
    }

    @JSProperty
    @Nullable
    EventListener getOncomplete();

    @JSProperty
    void setOncomplete(EventListener oncomplete);

    default void addCompleteEventListener(EventListener listener, AddEventListenerOptions options) {
        addEventListener("complete", listener, options);
    }

    default void addCompleteEventListener(EventListener listener, boolean options) {
        addEventListener("complete", listener, options);
    }

    default void addCompleteEventListener(EventListener listener) {
        addEventListener("complete", listener);
    }

    default void removeCompleteEventListener(EventListener listener, EventListenerOptions options) {
        removeEventListener("complete", listener, options);
    }

    default void removeCompleteEventListener(EventListener listener, boolean options) {
        removeEventListener("complete", listener, options);
    }

    default void removeCompleteEventListener(EventListener listener) {
        removeEventListener("complete", listener);
    }

    @JSProperty
    @Nullable
    EventListener getOnerror();

    @JSProperty
    void setOnerror(EventListener onerror);

    default void addErrorEventListener(EventListener listener, AddEventListenerOptions options) {
        addEventListener("error", listener, options);
    }

    default void addErrorEventListener(EventListener listener, boolean options) {
        addEventListener("error", listener, options);
    }

    default void addErrorEventListener(EventListener listener) {
        addEventListener("error", listener);
    }

    default void removeErrorEventListener(EventListener listener, EventListenerOptions options) {
        removeEventListener("error", listener, options);
    }

    default void removeErrorEventListener(EventListener listener, boolean options) {
        removeEventListener("error", listener, options);
    }

    default void removeErrorEventListener(EventListener listener) {
        removeEventListener("error", listener);
    }

    /**
     * Aborts the transaction. All pending requests will fail with a "AbortError" DOMException and all changes made to the database will be reverted.
     */
    void abort();

    /**
     * Returns an IDBObjectStore in the transaction's scope.
     */
    IDBObjectStore objectStore(String name);

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy