I was going to refactor one of my method from this:
if (!isMobileBluetoothOn()) {
sendError();
return false;
}
to this
getBluetoothState().subscribe(state->{
if(!state.isEnabled()){
sendError();
return false;
}
});
but I am getting this error in the IDE "UnExpected return value"
, How can I return the boolean value in the onSuccess method?
i'd suggest you to split logic here to something like:
Observable<Boolean> isBluetoothEnabled = getBluetoothState()
.map(state -> {state.isEnabled()})
.replay(1)
.refCount()
...
// use isBluetoothEnabled for something you need
...
isBluetoothEnabled
.subscribe(isEnabled -> {
if (!isEnabled) {
sendError()
}
})