Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
src
.gitignore
README.md
build.gradle
gradle.properties

README.md

RxJava2 Adapter

An adapter for adapting RxJava 2.x types.

Available types:

  • Flowable<T> with T being AtomFeed or RssFeed.
  • Maybe<T> with T being AtomFeed or RssFeed.
  • Single<T> with T being AtomFeed or RssFeed.

Usage

Pass RxJava2CallAdapterFactory as parameter to Syndication.

val syndicationReader = Syndication(
  url = "https://www.lequipe.fr/rss/actu_rss.xml",
  callFactory = RxJava2CallAdapterFactory.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 a Scheduler of your choice.
  • Use createAsync() when creating the factory which will use OkHttp's internal thread pool.
  • Use createWithScheduler(Scheduler) to supply a default subscription Scheduler.

Download

Download the latest JAR or grab via Gradle:

implementation 'com.ouattararomuald:syndication-rxjava2-adapter:0.1.0-rc.1'

or Maven:

<dependency>
  <groupId>com.ouattararomuald</groupId>
  <artifactId>syndication-rxjava2-adapter</artifactId>
  <version>0.1.0-rc.1</version>
</dependency>

Snapshots of the development version are available in Sonatype's snapshots repository.