I have many similar functions where I’m invoking a repository function inside a Coroutine and then processing it. The procedure is always the same, the only difference is what repository function I use and the parameters of it.
I cannot create a function like fun launchCoroutineAndCallRepoFunction(val repoFun: () -> Response) because those repository functions have various arguments.
What are my options to reduce code repetition? Specifically the logging, the coroutine scope, the repository function call and the response processing.
Also note that it wasn’t really that receiver that solved the problem. Your original function would be also fine (just after small fixes). I’ve got an impression that you tried to use your function like this: