Skip to content

Instantly share code, notes, and snippets.

@gpeal
Created July 24, 2018 06:27
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 gpeal/fcb2cd8ec42895c029b0ceb56e4f6a76 to your computer and use it in GitHub Desktop.
Save gpeal/fcb2cd8ec42895c029b0ceb56e4f6a76 to your computer and use it in GitHub Desktop.
MvRxFragmentExtension
fun <S : MvRxState> MvRxViewModel<S>.subscribe(
shouldUpdate: ((S, S) -> Boolean)? = null,
observerScheduler: Scheduler = AndroidSchedulers.mainThread(),
subscriber: ((S) -> Unit)? = null
) = subscribe(this@MvRxFragment, shouldUpdate, observerScheduler, subscriber ?: { if (readyToInvalidate()) invalidate() })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment