https://kotlinlang.org logo
#mvikotlin
Title
# mvikotlin
s

Seth Madison

03/01/2023, 12:15 AM
Are there patterns or best practices for modularizing executor code. It seems like for complex state it can get rather large. We’ve devised an idea of
SubExecutors
that we delegate to. Each
SubExecutor
is responsible for managing a subset of data (usually 1-to-1 with a backend endpoint). It gets a little icky, though because
SubExecutors
sometimes need reference to each other — not the end of the world, but it feels like there should be a better way.
a

Arkadii Ivanov

03/01/2023, 9:28 AM
The main idea is to write separate stores. E.g. having one Store per screen is usually fine. If you see that some part of the screen is self-contained, you can extract that part into a separate Store. Executors are normal classes, you can just extract methods with callbacks.
SubExecutors
should also work.
s

Seth Madison

03/01/2023, 2:31 PM
The problem that we run into with separate stores is that there is usually some data that needs to be shared across the screens and there ends up being cross-store dependencies (eg when store A changes we need to fire an intent into store B). We haven’t really found a clean way to manage that.
a

Arkadii Ivanov

03/01/2023, 2:33 PM
Yep. You can send Labels from one store, and then map them to Intents of another store. That's the expected usage.
s

Seth Madison

03/01/2023, 3:09 PM
Ah, got it. Maybe we can give that a try.
12 Views