https://kotlinlang.org logo
#orbit-mvi
Title
# orbit-mvi
k

kenkyee

11/04/2021, 4:20 PM
Is there any way to run intents multiple times in debug mode to verify that they don't have side effects (aka idempotent) like you can do with redux reducers or Mavericks?
m

Mikolaj Leszczynski

11/05/2021, 7:51 AM
I suggest just unit testing them, if they produce side effects that are not declared in the assertion it should fail the test.
k

kenkyee

11/05/2021, 10:32 AM
Then all the unit tests would have to do the run twice check probably. Mostly curious whether it's possible since it seems to be a common thing checked for in redux/MVI frameworks...
m

Mikolaj Leszczynski

11/05/2021, 10:32 AM
I am curious - why twice?
I’m guessing by side effects you do not mean the ones you send to the view?
k

kenkyee

11/05/2021, 10:36 AM
I think they check that reducers are "pure" https://airbnb.io/mavericks/#/debug-checks
So this isn't running the intent handler twice but reduce {} is done twice in debug mode.
m

Mikolaj Leszczynski

11/05/2021, 10:38 AM
I see, makes sense. We don’t currently have this, but we’ll consider building something like this in
👍 1
you can always wrap a unit test in
repeat(5) { … }
in the meantime 😅
unless this relies on having the same container for both reductions
also, I wonder if the idempotency check done by mavericks isn’t a fairly weak test anyway, as the reduction might appear idempotent for some input states, but not for others 🤔
k

kenkyee

11/05/2021, 11:20 AM
I think it requires the container so that's why it's a runtime check vs. a unit test rule.
m

Mikolaj Leszczynski

11/05/2021, 11:20 AM
unit tests run on the container as well
well - in a way
k

kenkyee

11/05/2021, 11:21 AM
True..hmm... Not sure why it couldn't be implemented as a unit test rule then 🤔
m

Mikolaj Leszczynski

11/05/2021, 11:21 AM
testing using real world use cases and data might be one reason
but this can be done in tests using fixtures
k

kenkyee

11/05/2021, 11:49 AM
Or if people forget to do tests...
😅 2
m

Mikolaj Leszczynski

11/05/2021, 12:41 PM
“forget”
🙂 2
4 Views