Created
February 2, 2019 03:29
-
-
Save kohendrix/caa9f1a75e486db1a0c4fc894cdedbb3 to your computer and use it in GitHub Desktop.
TwitterSample search() updated
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
| class MainViewModel : ViewModel() { | |
| private val repository = TweetsRepository() | |
| private val searchWords = MutableLiveData<String>() // trigger | |
| // tweet data exposed to Views | |
| val tweetDataResults: LiveData<TweetDataResult> | |
| = Transformations.switchMap(searchWords) { str -> repository.loadTweets(str) } | |
| /** | |
| * search trigger | |
| */ | |
| fun search(str: String) { | |
| Log.d(TAG, "search $str") | |
| searchWords.value = str | |
| } | |
| ... | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment