Pablichjenkov
08/13/2019, 8:14 PMFlow<T>. Is it a bad design?jw
08/13/2019, 8:14 PMsuspend fun?Pablichjenkov
08/13/2019, 8:16 PMjw
08/13/2019, 8:17 PMObservable is also somewhat incorrect for representing a network request. RxJava 2 fixed this with the Single type.Pablichjenkov
08/13/2019, 8:25 PMState.Loading, State.Data.
What I normally do is having an Interactor/Actor chaining the Observables. I would like to do the same with Flow. suspend works is just that the chain does not look the same.
My knowledge on coroutines is entry level, there is probably a better way.jw
08/13/2019, 8:26 PMSingle to Observable where necessary and suspend fun integrates into Flow operators as well.Pablichjenkov
08/13/2019, 8:29 PMsuspend fun integrates into Flow operators as well
Definitely a good approach, I haven’t tried. Thanks!gildor
08/13/2019, 11:19 PM::someFunction.asFlow()Pablichjenkov
08/13/2019, 11:52 PMretrofitApi.suspendingFunc() from an enclosing Flow or retrofitApi::suspendingFunc().asFlow().
If I want to propagate a custom CustomHttpException or CustomIOException down the stream. Should I enclose the retrofit api suspended call in a try/catch block, or append a .catch() operator after the Flow?
With Observables I use .onErrorReturn() operator to intercept erros.gildor
08/14/2019, 12:27 AMYou mean ::someSuspendFunction.asFlow right?It works for suspend and common functions
Pablichjenkov
08/14/2019, 12:27 AMgildor
08/14/2019, 12:30 AMretrofitApi::suspendFunc.asFlow() or suspend { retrofitApi.suspendFunc(param) }.asFlow()gildor
08/14/2019, 12:32 AMPablichjenkov
08/14/2019, 12:57 AM.asFlow() usage. I just corrected my post so it does not confuse any reader.
I see the point, I will move into that direction then.gildor
08/14/2019, 1:35 AMretrofitApi::suspendingFunc().asFlow() is still not correct, goal here is to convert method reference to flow, so when terminal operator will be called this method reference will be invoked by Flow chain