I use retrolambda expression
_rxBus = getRxBusSingleton();
_disposables = new CompositeDisposable();
ConnectableFlowable<Object> tapEventEmitter = _rxBus.asFlowable().publish();
_disposables
.add(tapEventEmitter.subscribe(event -> {
if (event instanceof EmployeeMvvmActivity.TapEvent) {
_showTapText();
}
}));
Everything work fine. Because of Roboelectric testing i need to convert retrolambda expression to classic. I have tried
_disposables.add(tapEventEmitter.subscribe(new Action1<Object>() {
@Override
public void call(Object event) {
if (event instanceof EmployeeMvvmActivity.TapEvent) {
_showTapText();
}
}
}));
I have got error cannot resolve method 'subscribe(anonymous rx.functions.Action1(java.lang.object)'.
The Action1
comes from Rx1 while you're using Rx2. Instead you have to use the Consumer
interface.
_disposables.add(tapEventEmitter.subscribe(new Consumer<Object>() {
@Override
public void accept(Object event) {
if (event instanceof EmployeeMvvmActivity.TapEvent) {
_showTapText();
}
}
}));