Kotlin Singleton With Parameter

January 22, 2019
@Volatile private var adapter: JsonAdapter<RateAppReminder>? = null

private fun getJsonAdapter(moshi: Moshi): JsonAdapter<RateAppReminder> = adapter ?: synchronized(this) {

NOTE: Refer to this example for optional parameter.

If no parameter is required, consider using lazy property.

val moshiStringListAdapter by lazy {

NOTE: To use lazy property with parameter, do look into this.

This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.