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

com.iodesystems.android.jsi.Deferred Maven / Gradle / Ivy

There is a newer version: 1.0.4
Show newest version
package com.iodesystems.android.jsi;

import com.iodesystems.android.jsi.handlers.Invokable;

public class Deferred {
    private Invokable successInvokable;
    private Invokable errorInvokable;

    public void resolve(Object success) {
        if (successInvokable != null) successInvokable.invoke(success);
    }

    public void reject(Exception error) {
        if (errorInvokable != null) errorInvokable.invoke(error);
    }

    public void then(Invokable success, Invokable onError) {
        this.successInvokable = success;
        this.errorInvokable = onError;
    }

    public void then(Invokable success) {
        this.successInvokable = success;
    }
}