Skip to content

Instantly share code, notes, and snippets.

@Skyyo
Created April 18, 2021 20:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Skyyo/cdbb811e199b5c6ff8865797de1f0376 to your computer and use it in GitHub Desktop.
Save Skyyo/cdbb811e199b5c6ff8865797de1f0376 to your computer and use it in GitHub Desktop.
class LifecycleAwareCurrenciesViewModel : ViewModel() {
private val _currencyPrices = MutableStateFlow(listOf<CurrencyPrice>())
val currencyPrices: StateFlow<List<CurrencyPrice>> get() = _currencyPrices
init {
getCurrencyPrices()
}
private fun getCurrencyPrices() {} //same as before
fun onCurrencyUpdated(newPrice: Int, index: Int) { } //same as before
fun provideCurrencyUpdateFlow(): Flow<Int> { } //same as before
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment