An adapter for adapting RxJava 3.x types.
Available types:
Flowable<T>
withT
beingAtomFeed
orRssFeed
.Maybe<T>
withT
beingAtomFeed
orRssFeed
.Single<T>
withT
beingAtomFeed
orRssFeed
.
Pass RxJava3CallAdapterFactory
as parameter to Syndication
.
val syndicationReader = Syndication(
url = "https://www.lequipe.fr/rss/actu_rss.xml",
callFactory = RxJava3CallAdapterFactory.create()
)
create and interface like the one below
interface RssReader {
fun readFlowable(): Flowable<RssFeed>
fun readMaybe(): Maybe<RssFeed>
fun readSingle(): Single<RssFeed>
}
then let Syndication
class generates an implementation of that interface RssReader
:
val reader = syndicationReader.create(RssReader::class.java)
reader.readFlowable().subscribe { rssFeed -> /* do something */ }
reader.readMaybe().subscribe { rssFeed -> /* do something */ }
reader.readSingle().subscribe { rssFeed -> /* do something */ }
By default all reactive types execute their requests synchronously. There are multiple ways to control the threading on which a request occurs:
- Call
subscribeOn
on the returned reactive type with aScheduler
of your choice. - Use
createAsync()
when creating the factory which will use OkHttp's internal thread pool. - Use
createWithScheduler(Scheduler)
to supply a default subscriptionScheduler
.
Download the latest JAR or grab via Gradle:
implementation 'com.ouattararomuald:syndication-rxjava3-adapter:2.1.1'
or Maven:
<dependency>
<groupId>com.ouattararomuald</groupId>
<artifactId>syndication-rxjava3-adapter</artifactId>
<version>2.1.1</version>
</dependency>
Snapshots of the development version are available in Sonatype's snapshots repository.