Skip to content

Latest commit

 

History

History

syndication-rxjava3-adapter

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

RxJava3 Adapter

An adapter for adapting RxJava 3.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 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 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-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.