Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where can AndroidObservable.fromBroadcast be found now?

Before 1.0.0 there was AndroidObservable class with fromBroadcast method in RxAndroid which would be used to subscribe for broadcast in reactive way. It was mentioned in Grokking RxJava:

I also like AndroidObservable.fromBroadcast(), which allows you to create an Observable that works like a BroadcastReceiver. Here's a way to be notified whenever network connectivity changes:

IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
AndroidObservable.fromBroadcast(context, filter)
                 .subscribe(intent -> handleConnectivityChange(intent));

After 1.0.0, RxAndroid dropped a lot of functionality and splitted into RxAndroid itself which now has only threading stuff, RxLifecycle and RxBindings.

None of them seem to contain AndroidObservable with fromBroadcast or fromSharedPreferenceChange.

Is it implemented in some actual and supported library?

like image 256
hotkey Avatar asked Jan 03 '16 10:01

hotkey


2 Answers

This functionality was removed in 1.0 release as part of modularization effort. You can find a replacement in RxBroadcast. To use it add a dependency to build.gradle:

compile 'com.cantrowitz:rxbroadcast:1.0.0'

And use it as follows:

Observable<Intent> = RxBroadcast.fromBroadcast(context, intentFilter);
like image 109
miensol Avatar answered Nov 12 '22 10:11

miensol


In short, it has been removed and I don't know of any replacement yet.

You can see here that it was renamed to AppObservable, and then here that it has been removed with the 1.0 release where they did quite some cleaning.

There seem to have been some severe issues.

like image 30
David Medenjak Avatar answered Nov 12 '22 12:11

David Medenjak