0

I am struggling with preventing call all methods in class hierarchy chain. Lets say i have a base class:

class BaseModel 

{ /* Some basic fields goes here */ }

class ModelCompany extends BaseModel

{ /* Fields goes here */ }

Then I want to post two different events:

BaseModel oneEvent = new BaseModel();

ModelCompany otherEvent = new ModelCompany();

EventBus.getDefault().post(oneEvent);

EventBus.getDefault().post(otherEvent);

Somewhere in the activity:

onEvent(BaseModel ev1){}

onEvent(ModelCompany ev2){}

The thing is that both onEvent method will be executed in this case. How to prevent it and post message to exact method?

Sergey Glotov
  • 20,200
  • 11
  • 84
  • 98

1 Answers1

1

It is possible in EventBus 3 with EventBusBuilder.eventInheritance()

Sergey Glotov
  • 20,200
  • 11
  • 84
  • 98