Saturday, June 22, 2013

Re: HandlerRegistration.removeHandler() does not work?

Oh, thank Thomas. 

I have solved the problem. The problem caused by an other activity that fires the LoginSuccessEvent. I forgot to removeHandler() on that activity, so It fires the  LoginSuccessEvent multiple times.

2013/6/22 Thomas Broyer <t.broyer@gmail.com>


On Saturday, June 22, 2013 3:40:21 AM UTC+2, Sang Hero wrote:
Hi everyone,

I have had a problem with HandlerRegistration returned by method SimpleEventBus.addHandler 

When I call:

HandlerRegistration hr = eventBus.addHandler(LoginSuccessEvent.TYPE, new LoginSuccessEventHandler() {
@Override
public void onSuccess(LoginSuccessEvent event) {
view.getName().setText(event.getName());
System.out.println("Fire");
}
});

Then I call:

hr.removeHandler();

The handler still does not be removed. I see on console multiple "Fire" each event firing.

This is my complete code: http://pastebin.com/3ZBXnXF8

On each event firing, I see "Back" one time but multiple time with "Fire"

Can you help me solve this problem?

Hard to diagnose with the given information (where and when the LoginSuccessEvent is fired?), but you actually don't need that 'hr', because the EventBus passed to start() will automatically un-register all its handlers when the activity stops (onStop and onCancel).

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment