<@UHAJKUSTU> Is there any approach to use the DSL ...
# mvikotlin
e
@Arkadii Ivanov Is there any approach to use the DSL (coroutineExecutorFactory) and keep the exhaustive nature of
when
block of the regular Executor for Intents?
a
Technically, you can write
Copy code
onIntent<Intent> { intent ->
    when (intent) {
        // ...
    }
}
But I think this is not what you want. You can also try creating your own API, something like this:
Copy code
executorFactory(
    onIntent = { intent ->
    },
    onAction = { action -> 
    }
}
e
Yes, I thought about creating my own API, but decided to ask first. Maybe it is a usual request 😀
👍 1
Is it possible to remove
private
accessor from the
ExecutorImpl
in
CoroutineExecutorDsl
in next versions? It would be much easier to make own DSL then. I can’t just copy it, because it uses internal
atomic
. Is it critical to use atomic here? The
callbacks
field is written only once in
init
function.
a
You don't need atomics actually in that case, because by design it can only be accessed on the main thread. The only purpose of atomic there is to provide one-time lazy initialization with error on the second attempt.
I don't like the idea of exposing implementation details like ExecutorImpl, sorry.
e
So
atomic
could be replaced by something like
Delegates.notNull
, right?
Got it. Does it make sense to make a pull request with an alternative exhaustive DSL functions?
a
Yes. But I'm not sure if it will throw an error on the second initialization attempt, which I wanted to have.
I would like to see the API first, if possible 😀
👍 1
👌 1
e
Agree. It should be something similar but with this check.
👍 1