Hello everyone! A few times I received feedback th...
# mvikotlin
a
Hello everyone! A few times I received feedback that there is some boilerplate when implementing a Store. I have some ideas of how to improve things, but I would like to run a poll first. Could you please vote how do you like the current experience? Thanks! ๐Ÿ™‚ - I like the current experience, don't touch! ๐Ÿ˜ - Would be good to improve ๐Ÿ™ - Definitely needs improvement! ๐Ÿ™ƒ - I don't care
๐Ÿ˜ 9
a
Can you share your ideas?
a
Well, I could not find any way to somehow significantly improve it. Taking into account the following requirements: 1. Compile time safety - if you add e.g. a new Intent, Result, Action, etc. then the code does not compile until covered 2. Logging of communications between store components 3. Time travel This is what I have in mind at the moment, it doesn't even require API changes: https://gist.github.com/arkivanov/77c41c3545fbe81358bd4627c3346506 I will keep thinking about it for a while.
๐Ÿ™๐Ÿป 1
i
I like that a lot! Anything to make it simpler and easier to reason about it a benefit.
a
Well, there is no need to change anything. The demonstrated approach can be used with the current API.
n
Looks neat! You say
less compile-time safety
. From looking at the code i see that building executorFactory is less safe because you could forget to process new intent, right? Is there anything else?
a
Yes exactly. You may forget to handle newly added intents or actions.
t
Maybe the MVIKotlin IDEA Plugin could provide an Inspection on unhandled Intents/Actions? Or would it even be possible to configure such Inspection?
a
Yeah maybe, not sure yet. If the DSL will be released, I would collect feedback first.
a
Boilerplate can be solved by creating a template for the initial Store setup. Creating just the structure of Store and its Model + Intents. Personally I don't like this DSL approach. As you already pointed out it is less compile-time safe and a lot of developers I know nowadays prefer compile-time safety. If I would present this as a PR to my team, it would most likely get rejected.
a
Thanks for the feedback! Templates are indeed good. Please note, the proposed DSL is just an idea and is on top of the existing API. So for example it can be used only in a simple Store implementation.