EventBus icon indicating copy to clipboard operation
EventBus copied to clipboard

when post an envent about list<*> , anyplace that Subscribe List<*> will get Event...

Open Liberations opened this issue 8 years ago • 2 comments

I hava to use instanceof to avoid add datas that I don't want....Can you add some judgment

  /*instanceof to avoid some bug...*/
@Subscribe(sticky = true)
public void getMettingMem(List<MettingMem.Mem> mettings) {
	for (Object obj : mettings) {
		if (!(obj instanceof MettingMem.Mem)) {
			return;
		}
	}
	this.mettings = mettings;
	Logger.d("msgSize"+mettings.size());
}

Liberations avatar Dec 06 '17 03:12 Liberations

Do not use Generic, generic type is erased at runtime You should wrap your data

class MeetingsEvent {

      public final List<MettingMem.Mem> mettings;

      MeetingsEvent(List<MettingMem.Mem> mettings) {
              this.mettings = mettings
      }
}
@Subscribe(sticky = true)
public void getMettingMem(MeetingsEvent event) {
	this.mettings = event.mettings;
	Logger.d("msgSize"+this.mettings.size());
}

kukuhyoniatmoko avatar Dec 14 '17 10:12 kukuhyoniatmoko

thank U

Liberations avatar Dec 16 '17 03:12 Liberations