Guest User

Untitled

a guest
Jul 27th, 2020
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 1.05 KB | None | 0 0
  1. class ViewModelBinding : DisposableScope by DisposableScope() {
  2.  
  3.     fun <T> subscribe(
  4.         observable: Observable<T>,
  5.         isThreadLocal: Boolean = true,
  6.         onSubscribe: ((Disposable) -> Unit)? = null,
  7.         onError: ((Throwable) -> Unit)? = null,
  8.         onComplete: (() -> Unit)? = null,
  9.         onNext: ((T) -> Unit)? = null
  10.     ) {
  11.         observable.subscribeScoped(
  12.             isThreadLocal = isThreadLocal,
  13.             onSubscribe = onSubscribe,
  14.             onError = onError,
  15.             onComplete = onComplete,
  16.             onNext = onNext
  17.         )
  18.     }
  19.  
  20.     fun <T> subscribe(
  21.         observable: Observable<T>,
  22.         onError: ((Throwable) -> Unit)? = null,
  23.         onNext: ((T) -> Unit)? = null
  24.     ) {
  25.         observable.subscribeScoped(
  26.             isThreadLocal = true,
  27.             onError = onError,
  28.             onNext = onNext
  29.         )
  30.     }
  31.  
  32.     fun <T> subscribe(observable: Observable<T>, onNext: ((T) -> Unit)? = null) {
  33.         observable.subscribeScoped(isThreadLocal = true, onNext = onNext)
  34.     }
  35. }
  36.  
Advertisement
Add Comment
Please, Sign In to add comment