Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
fun AppCompatActivity.subscribeToBroadcastsOnLifecycle(action: String, fn: (Intent) -> Unit) {
observeBroadcasts(action).subscribeOnLifecycle(lifecycle, fn)
fun <T> Observable<T>.subscribeOnLifecycle(lifecycle: Lifecycle, fn: (T) -> Unit) {
val lifecycleObserver: LifecycleObserver = object : LifecycleObserver {
private var subscription: Disposable? = null
fun onStart() {
subscription = subscribe(fn)
fun onStop() {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment