title: RxJava: how to return the correct type of null
body: <p>I'm developing an app using Firebase, Kotlin and RxJava.</p>
  
  <p>Basically, what I need to do is register an user using Auth from Firebase, if the user selected a photo, upload the photo and then save the user in the database from Firebase. </p>
  
  <p>Until now I have this</p>
  
  <pre><code>RxFirebaseAuth.createUserWithEmailAndPassword(auth, email, password)
              .map { authResult -&gt;
                  user.uid = authResult.user.uid
                  authResult.user.uid
              }
              .flatMap&lt;UploadTask.TaskSnapshot&gt;(
                      { uid -&gt;
                          if (imageUri != null)
                              RxFirebaseStorage.putFile(mFirebaseStorage
                                      .getReference(STORAGE_IMAGE_REFERENCE)
                                      .child(uid), imageUri)
                          else
                              Maybe.empty&lt;UploadTask.TaskSnapshot&gt;()
                      }
              )
              .map { taskSnapshot -&gt; user.photoUrl = taskSnapshot.downloadUrl!!.toString() }
              .map {
                  RxFirebaseDatabase
                          .setValue(mFirebaseDatabase.getReference("user")
                                  .child(user.uid), user).subscribe()
              }
              .doOnComplete { appLocalDataStore.saveUser(user) }
              .toObservable()
  </code></pre>
  
  <p>It's working correctly when the user selects a photo, but when it's not selected, the other maps are ignored, because I returned Maybe.empty().</p>
  
  <p>How should I implement this to work with or without a user photo?</p>
  
  <p>Thanks.</p>