v1.1.0
PINkman meets the asynchronous world.
PINkman adds support for Kotlin Coroutines and RxJava 3. From this release on, you can call several methods in async manner:
fun createPinAsync(...): Completable
fun changePinAsync(...): Completable
fun isValidPinAsync(...): Single<Boolean>
// Coroutines
suspend fun createPinAsync(...)
suspend fun changePinAsync(...)
suspend fun isValidPinAsync(...): Boolean
So, you can refactor your CreatePinViewModel
as following:
class CreatePinViewModel @ViewModelInject constructor(private val pinkman: Pinkman) : ViewModel() {
val pinIsCreated = MutableLiveData<Boolean>()
fun createPin(pin: String) {
viewModelScope.launch {
pinkman.createPinAsync(pin)
pinIsCreated.postValue(true)
}
}
}