quick question: On a ktor client app I’m trying to...
# kotlinx-rpc
m
quick question: On a ktor client app I’m trying to get the rpc client and add it into the dependency injection tree.In the documentation I see something as easy as:
Copy code
val rpc = httpClient.rpc {
    //config
}
But
rpc()
is suspending. How are we suposed to create this dependency and add it to a module in
Koin
for example (just said an arbitrary DI lib on kotlin)
d
Instead of injecting RPC Client instance itself, you can use Koin to inject the RPC client creation function as a lambda, then invoke that as soon as you hit your suspending context.
This aspect of RPC client creation is a little unergonomic I agree; but probably there are reasons why it has to be this way...
m
should it behave as a singleton or is it safe to call the creation function N times ad hoc?