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