Created
September 6, 2019 06:39
-
-
Save jmfayard/e7b3c383db5e04344552754ad7eac354 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object MoshiAdapters { | |
val moshi : Moshi = Moshi.Builder().build() | |
inline fun <reified T: Any> moshiAdapter(clazz: Class<T> = T::class.java): Lazy<JsonAdapter<T>> | |
= lazy { moshi.adapter(clazz) } | |
val movie: JsonAdapter<Movie> by moshiAdapter() | |
val user: JsonAdapter<User> by moshiAdapter() | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment