https://kotlinlang.org logo
#ktor
Title
# ktor
c

CLOVIS

02/09/2020, 7:15 PM
Also, do you think it is better practice to call
HttpClient()
in the common code, or to
expect
the client from each platform to have more granular settings (but maybe code duplication as well?)
r

russhwolf

02/09/2020, 11:24 PM
I typically inject an
HttpClientEngine
that varies by platform and have a single
HttpClient
defined in common which uses it. Can inject via `expect`/`actual` or your favorite DI pattern from your platform code.
👍 1
c

CLOVIS

02/10/2020, 5:33 PM
Thanks, I'll look into that 👍
If you were working on a library that is mostly a wrapper around a single REST API, would you have a single long-running client for the lifetime of the program, or create/close it repeatedly (eg. On Android, when an activity dies or is created)?