promise in popup

This commit is contained in:
2015-07-17 21:36:55 +03:00
parent 18808764f9
commit 047db87a25

View File

@@ -1,7 +1,6 @@
package haxework.gui.popup;
import haxework.net.callback.Callback;
import haxework.net.callback.ICallback;
import promhx.Deferred;
import haxe.Timer;
import haxework.provider.Provider;
import haxework.dispath.Dispatcher;
@@ -15,7 +14,7 @@ class PopupView<V:IView> extends GroupView {
private var buttonId:String;
private var contentView:V;
private var callback:ICallback<String>;
private var deferred:Deferred<String>;
public function new(contentViewFactory:Class<V>) {
super();
@@ -34,10 +33,10 @@ class PopupView<V:IView> extends GroupView {
close();
}
public function show():ICallback<String> {
public function show():Deferred<String> {
Provider.get(PopupManager).show(this);
callback = Callback.build();
return callback;
deferred = new Deferred<String>();
return deferred;
}
public function close():Void {
@@ -49,9 +48,9 @@ class PopupView<V:IView> extends GroupView {
}
public function onClose():Void {
if (callback != null) {
callback.callSuccess(buttonId);
callback = null;
if (deferred != null) {
deferred.resolve(buttonId);
deferred = null;
}
}
}