MVIKotlin icon indicating copy to clipboard operation
MVIKotlin copied to clipboard

Consider better names for Action and Result

Open arkivanov opened this issue 2 years ago • 3 comments

Currently Actions are sent from Bootstrapper to Executor and Results are sent from Executor to Reducer. But sometimes it might be confusing, because we need to send an action to the Reducer, or a result to the Executor. Maybe we should find neutral names instead?

arkivanov avatar Oct 17 '21 10:10 arkivanov

Can you elaborate on this part @arkivanov ?

we need to send an action to the Reducer, or a result to the Executor

What would be an example of sending an action to a Reducer or a result to the Executor?

Nikola-Milovic avatar Oct 31 '21 12:10 Nikola-Milovic

@Nikola-Milovic

What would be an example of sending an action to a Reduce

If a Store don't need any async processing, then the Executor can be avoided, and so the Reducer processes Intents directly. Intents are calls to actions, they are usually written as imperative verbs, e.g. Intent.RemoveUser. In this case the Reducer processes commands, not results.

Another case could be, when you did some calculations in the Executor. And as a result you might want to express a command to the Reducer to change the state in some way.

Another case is when you actually have Executor, because some of the Intents needs async processing, but some of them do not. E.g. if you have Intent.ToggleFavoriteStatus, then in the Executor it is inconvenient to express it as a result. It is still a command, just redispatched.

a result to the Executor

There are cases when you subscribe to events in the Bootstrapper, for example server notifications. You might want to dispatch something like UserSignedOut, which is an event, not an action.

arkivanov avatar Oct 31 '21 12:10 arkivanov

Moved to https://github.com/arkivanov/MVIKotlin/issues/6

arkivanov avatar Dec 17 '21 09:12 arkivanov