父演示者未处理我的激发GWT事件
我有一个子演示器(添加到插槽中的父演示器),当调用父演示者未处理我的激发GWT事件,gwt,gwtp,gwt-platform,event-bus,Gwt,Gwtp,Gwt Platform,Event Bus,我有一个子演示器(添加到插槽中的父演示器),当调用onBind()时,它通过eventBus(在一定条件下)触发事件: class ChildPresenter extends PresenterWidget<?> { void onBind() { instance = initMyInstance(); if (instance == null) {
onBind()
时,它通过eventBus
(在一定条件下)触发事件:
class ChildPresenter extends PresenterWidget<?> {
void onBind() {
instance = initMyInstance();
if (instance == null) {
eventBus.fireEvent(new MyEvent());
}
}
//...
}
我也在父级中尝试了这一点:addRegisteredHandler(LoggedOutEvent.TYPE,this)
和addVisibleHandler(…)
,在父级演示器中实现了MyEventHandler
接口,但它不处理激发的事件
我做错了吗?我还注意到,当我将处理过程移动到父演示者的
onReveal()
方法时,它只运行了两次 您很可能有时间问题。确保在子级中激发之前调用父级中的addHandler(),并且我认为它应该在单独的浏览器事件中发生。尝试以下方法,看看是否有帮助:
class ChildPresenter extends PresenterWidget<?> {
void onBind() {
instance = initMyInstance();
if (instance == null) {
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
eventBus.fireEvent(new MyEvent());
}
});
}
}
//...
}
class ChildPresenter扩展了PresenterWidget{
void onBind(){
instance=initMyInstance();
if(实例==null){
Scheduler.get().ScheduledDeferred(新的ScheduledCommand(){
@凌驾
public void execute(){
fireEvent(新的MyEvent());
}
});
}
}
//...
}
您很可能有时间问题。确保在子级中激发之前调用父级中的addHandler(),并且我认为它应该在单独的浏览器事件中发生。尝试以下方法,看看是否有帮助:
class ChildPresenter extends PresenterWidget<?> {
void onBind() {
instance = initMyInstance();
if (instance == null) {
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
eventBus.fireEvent(new MyEvent());
}
});
}
}
//...
}
class ChildPresenter扩展了PresenterWidget{
void onBind(){
instance=initMyInstance();
if(实例==null){
Scheduler.get().ScheduledDeferred(新的ScheduledCommand(){
@凌驾
public void execute(){
fireEvent(新的MyEvent());
}
});
}
}
//...
}
通过onBind
方法,您试图实现什么?此方法在初始化presenter时只调用一次,而不会调用。应在onBind()方法中添加处理程序。这是一个时间问题。子演示者在父级添加事件处理程序之前触发了该事件。通过onBind
方法,您试图实现什么?此方法在初始化presenter时只调用一次,而不会调用。应在onBind()方法中添加处理程序。这是一个时间问题。子演示者在父级添加事件的处理程序之前触发了该事件。