Maurice Jouvet
07/09/2020, 1:51 PM// UseCase
suspend fun run(params: LoginModel): Token = authenticationRepo.auth(params)
It's easy on Android but on iOS I'm struggling.. I used to create a Protocol and a view that is the copy of the android version, but I have to work with event and callbacks.
Is there an "easy way" to do the same android call that on iOS :
@UiThread
fun authenticateAsync(loginModel: LoginModel): Deferred<Token> {
return viewModelScope.async {
authenticationTokenUseCase.run(loginModel)
}
}streetsofboston
07/09/2020, 1:53 PMMaurice Jouvet
07/09/2020, 1:54 PMMaurice Jouvet
07/09/2020, 1:55 PMbsimmons
07/09/2020, 1:58 PMstreetsofboston
07/09/2020, 2:01 PMObservable<T> instances and class Observable<T> is of our own making.
The Observable take a viewModelScope when created and receive the CoroutineScope from the UI (lifecycleObserver of Activity or Fragment) when observed. For iOS, for now, the CoroutineScope from the UI is just null and it will use the viewModelScope instead (ie ViewModel’s scope/lifecycle is the same as the scope of the iOS UI)
The UI, in both Android and iOS, creates an instance of this Observable with a plain callback (T) -> Unit (iOS) or suspend (T) -> Unit (Android). The inner-workings of the Observable will call this callback when appropriate.streetsofboston
07/09/2020, 2:01 PMObservable classMaurice Jouvet
07/09/2020, 2:07 PMstreetsofboston
07/09/2020, 2:10 PMArkadii Ivanov
07/09/2020, 4:49 PMArkadii Ivanov
07/09/2020, 4:50 PMstreetsofboston
07/09/2020, 4:57 PMMaurice Jouvet
07/09/2020, 8:04 PMArkadii Ivanov
07/09/2020, 8:36 PM