Search code examples
androidkotlinrx-javarx-kotlin

RXKotlin how do you map to void?


Sorry nooby kotlin question

func someThingElse(): Observable<String> {
   return Observable.just("aasd")
} 

fun doSomething(): Observable<Void> {
    return someThisElse().fetch().map { () } 
}

How do i return an observable of void? I tried void, Void(), Void


Solution

  • Unit in Kotlin corresponds to void in Java. Like void, Unit is the default return type of any function in Kotlin that does return anything.

    Using Completable, Single or Maybe might make more sense though