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