Skip to content

Instantly share code, notes, and snippets.

@JoseAlcerreca
Last active September 2, 2019 15:59
Show Gist options
  • Save JoseAlcerreca/b7781012318f488f45852dcfb04537ae to your computer and use it in GitHub Desktop.
Save JoseAlcerreca/b7781012318f488f45852dcfb04537ae to your computer and use it in GitHub Desktop.
/* Copyright 2019 Google LLC.
SPDX-License-Identifier: Apache-2.0 */
class MyViewModel : ViewModel() {
private val _liveData1 = MutableLiveData<String>()
val liveData1: LiveData<String> = _liveData1
// [Transformations.map] on liveData1 that converts the value to uppercase:
val liveData2 = _liveData1.map { it.toUpperCase() }
fun setNewValue(newValue: String) {
_liveData1.value = newValue
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment