/*
 * Copyright (C) 2015 Actor LLC. <https://actor.im>
 */

package im.actor.runtime.js.utils;

import com.google.gwt.core.client.JavaScriptObject;

import im.actor.runtime.promise.Promise;

public class JsPromise extends JavaScriptObject {

    public static <T> JsPromise from(Promise<T> promise) {
        create(new JsPromiseExecutor() {
            @Override
            public void execute() {
                promise.then(this::resolve)
                        .failure(this::reject);
            }
        });
        return null;
    }

    public static native JsPromise create(JsPromiseExecutor executor)/*-{
        var _executor = executor
        return new Promise(function (resolve, reject) {
            _executor.@im.actor.runtime.js.utils.JsPromiseExecutor::performExecute(*)(resolve, reject);
        });
    }-*/;

    protected JsPromise() {

    }
}
@@ -302,16 +302,23 @@
         
+return 
 create(n
@@ -522,29 +522,8 @@
 %7D);%0A
-        return null;%0A
     

return created promise from Promise.from