Created
March 1, 2020 20:03
-
-
Save lordcodes/25f2bf23537b1bc256d3c359fff48091 to your computer and use it in GitHub Desktop.
Code for the article: "The power of lazy properties in Kotlin"
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 TeamRepository(appSchedulers: AppSchedulers) { | |
| private val viewState by lazy(::createViewStateLiveData) | |
| private fun createViewStateLiveData(): LiveData<ViewState> = | |
| teamRepository.teamMembersStream() | |
| .map(::mapPresentingState) | |
| .onErrorReturn(::mapErrorState) | |
| .startWith(ViewState.Loading) | |
| .subscribeOn(appSchedulers.io) | |
| .observeOn(appSchedulers.main) | |
| .toLiveData() | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment