Let's use this class for the example:
public static class CurrentUser{
public static Observable<User> get(){
//code basically returns the currently logged in User object
//but sometimes there may not be a logged in user
}
public static Observable<PutResult> logOut(){
return get()
//I only want to execute the following if user != null
.flatMap(new Func1<User, Observable<PutResult>>() {
@Override
public Observable<PutResult> call(User user) {
//delete the session token and save
user.removeSessionToken();
return DatabaseModule.getStorIOSQLite()
.put()
.object(user)
.prepare()
.asRxObservable();
}
});
}
}
Should I just return null inside the flatmap? Are there any repercussions to this since it's expecting an Observable?