sebastien.rouif
10/30/2019, 11:12 AMMikolaj Leszczynski
10/31/2019, 11:08 AM1.2.0
has been released with a minor improvement to the DSL 🙂Carlos Muñoz
11/04/2019, 11:00 AMStatus<T>
class to be used as the output of any transformation (basically the result type of our use case executions). It can take the values Status.Failure(e: Throwable
, Status.Loading
, and Status.Result(payload: T)
.
- Listen to any possible resulting status of a given type and reduce them all together.
- If necessary, listen to specific result statuses separately.
In the case shown below, side effects are different (Status.Loading
doesn't have side effects, Status.Result
posts a side effect, Status.Failure
has both internal and view related side effects).Mikolaj Leszczynski
11/12/2019, 10:53 AMexpensivebelly
11/15/2019, 10:13 AMFirst/Second/Third retry attempt
and then either fail or succeed at that point? ThanksMikolaj Leszczynski
11/20/2019, 4:58 PMsebastien.rouif
04/29/2020, 11:03 AMkikermo
05/03/2020, 11:10 AMeventObservable
and currentState
to my transformers that I have defined outside (similar to the example). When I pass that currentState
, I am passing its value on the cretion of the stream so it will always be the initial version of that state. In order to have the latest value of that state, the actual current state, what I did was looping back an object that had the things I needed from the state to make my request. That solves my problem, but I was thinking what other alternatives we have. One would be modifying the stream with a map
but maybe there is a more obvious one I am missing. Thanks in advance.Giacomo De Bacco
05/25/2020, 1:38 PMMikolaj Leszczynski
03/05/2021, 3:02 PMRavi
03/28/2021, 10:47 PM@Composable
fun SomeCompose(viewModel: SomeViewModel){
val someState = viewModel.container.stateFlow.collectAsState(initial = initialState)
}
we can get initial state from (Mutable)StateFlow and collectAsState()Oleksii Malovanyi
03/30/2021, 2:47 PMContainer.Settings
of type CoroutineExceptionHandler
, so we could have a default exception handler for Android ViewModel?Oleksii Malovanyi
04/19/2021, 6:47 AMmiqbaldc
04/22/2021, 9:06 AMval state = MutableStateFlow(...)
state.map {
// a reducer
}.catch {
// catch the exception happened in a reducer
}
suggestion:
reduce {
// omitted
}.catch {
when (exception) {
// to distinguish between stateA & stateB exception, unless it's a general toast
ExceptionFromStateA -> state.copy(a = // do something with data specific to stateA)
ExceptionFromStateB -> state.copy(b = // similar to the above apprach)
}
// or a general error message
state.copy(errorMessage = it.message)
}
miqbaldc
04/27/2021, 4:47 AMunable to find the samples in orbit-mvi though, did I miss something? 🙏Been reading this article and seems
StateFlow
& Android lifecycle required additional configuration (there’s a new API from google to support this)
also there’s an interesting discussion about it in hereOleksii Malovanyi
04/29/2021, 1:00 PMflow<Unit> {
while (true) {
delay(3000)
emit(Unit)
}
}.flowOn(<http://Dispatchers.IO|Dispatchers.IO>).onEach { _ ->
intent { reduce { it } }
}.launchIn(viewModelScope)
Unfortunately intent
coroutine couldn’t be used for this, as it would block all new messages from the RealContainer’s channel
intent {
flow<Unit> {
while (true) {
delay(3000)
emit(Unit)
}
}.flowOn(<http://Dispatchers.IO|Dispatchers.IO>).onEach { _ ->
intent { reduce { it } }
}.collect()
}
Mikolaj Leszczynski
04/30/2021, 6:00 AMmiqbaldc
05/04/2021, 8:49 AMgreat talks▾
Oleksii Malovanyi
06/10/2021, 3:51 PMdelay()
if occurs inside the intent
block? I’ve tried to pass TestCoroutineDispatcher
as the orbitDispatcher
and then advanceTimeBy
but it has no effect and I have to wait for the delay to finish 😞asyn
06/13/2021, 10:35 AMSami Eljabali
06/15/2021, 9:55 PMmiqbaldc
06/16/2021, 8:29 AMMikolaj Leszczynski
06/28/2021, 12:17 PMOleksii Malovanyi
06/30/2021, 3:14 PMexceptionHandler
is never used so any exception would go to the TestCoroutineExceptionHandler
which would fail the test afterwards (runBlockingTest is used)Oleksii Malovanyi
07/02/2021, 10:01 AMOleksii Malovanyi
07/02/2021, 10:54 AMrunOnCreate
in tests -> it blocks, so if you have a delay or withTimeout call right when the container is created, your test would still be live timed 😞
https://github.com/orbit-mvi/orbit-mvi/pull/53miqbaldc
07/13/2021, 2:07 PMRavi
07/15/2021, 2:14 PMOleksii Malovanyi
07/16/2021, 3:09 PMintent{}
– it’s never canceled on parent’s scope.cancel
in case there is an exceptionHandler
installed, e.g.: something like this would create a mem. leak:
) : ViewModel(),
ContainerHost<ProfileState, ProfileEffect> {
override val container: Container<ProfileState, ProfileEffect> = container(
initialState = ProfileState(authorized = null, account = null),
savedStateHandle = savedStateHandle,
settings = Container.Settings(exceptionHandler = exceptionHandler.asCoroutineExceptionHandler()),
) {
intent {
subscribeToSessionUseCase().collect {
reduce { state.copy(authorized = it != null) }
}
}
}
Here is the sneak peak of the fix – I gonna create a test for that, but wonna let you know early
https://github.com/orbit-mvi/orbit-mvi/pull/58Mikolaj Leszczynski
07/19/2021, 9:06 PM4.1.3
has been released with yet another fix provided by @Oleksii Malovanyi!Mikolaj Leszczynski
07/19/2021, 9:06 PM4.1.3
has been released with yet another fix provided by @Oleksii Malovanyi!miqbaldc
07/21/2021, 12:12 AMEric Ampire [MOD]
08/04/2021, 9:54 PM