GWT 2.1: ResettableEventBus not reset?

public class MyActivity extends AbstractActivity implements ContextChangedEvent.Handler
{
    public MyActivity()
    {
        ClientFactory.INSTANCE.getEventBus().addHandler(ContextChangedEvent.TYPE, this);
    }

    @override
    public void onContextChanged()
    {
        //do stuff
    }
}



//The getEventBus Implementation:
public EventBus getEventBus()
{
    if (eventBus == null)
        eventBus = new ResettableEventBus(new SimpleEventBus());
    return eventBus;
}

When I add a breakpoint in the onContextChange () method, I get the following behavior:

  • in the first place, I break only once for each event.
  • after the place has changed, I will break twice
  • after another place change, 3 times ....

Since I use a new instance of MyActivity for each location, I assume that I am splitting multiple instances of MyActivity. ResettableEventBus should unregister all handlers with every change of location.

Am I missing something?

+3
source share
1 answer

ResettableEventBus removeHandlers ( ), . ResettableEventBus , .

ActivityManager eventbus, ActivityManager EventBus ResettableEventBus .

ActivityManager(myActivityMap, ClientFactory.INSTANCE.getEventBus());

...

public class MyActivity extends AbstractActivity implements ContextChangedEvent.Handler
{
    public MyActivity()
    {
    }

    @override
    public void onContextChanged()
    {
        // do Stuff
    }

    @override
    public void start(AcceptsOneWidget panel, EventBus eventBus) {
        eventBus.addHandler(ContextChangedEvent.TYPE, this);
    }
}

eventBus, "start", ActivityManager , .

SimpleEventBus factory ResettableEventBus. ResettableEventBus , , ( ).

http://code.google.com/p/google-web-toolkit/issues/detail?id=5700

FYI. eventbus. , .

+3

Source: https://habr.com/ru/post/1786406/


All Articles