uber/simple-store

putString when wrapped with Completable.fromFuture() seems to run immediately

Closed this issue · 4 comments

Describe the bug
putString when wrapped with Completable.fromFuture() seems to run immediately. Verified via debugger.

Maybe be specific to the instance when checking for said key before writing to SimpleStore

To Reproduce
Code Setup:

val setValue = Completable.fromFuture(simpleStore.putString(key, value))
val checkKeyFirst = Single.fromFuture(simpleStore.containsSingle(key))
checkKeyFirst.flatMapCompletable { isSet -> 
    if(isSet){ throw IllegalStateException() } else { setValue }
}

Expected behavior
Value should only be placed in SimpleStore when Completable has been subscribed to

Smartphone (please complete the following information):

  • Device: various
  • OS: Android 10

I realize after writing this that this maybe an issue within Rx. Either way I think its important to highlight the issue in case anyone else runs into it.

If a failing unit test can be written, that would be great.

a failing unit test can be written and called in a separate project

This is the nature of Single.fromFuture / Completable.fromFuture. These API are blocking.

Converts a Future into a Single and awaits its outcome in a blocking fashion.