Last active
September 2, 2019 15:59
-
-
Save JoseAlcerreca/b7781012318f488f45852dcfb04537ae 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
/* 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