simplepoller

A dead simple polling implementation in kotlin coroutines and flow

License

License

GroupId

GroupId

me.nikhilchaudhari
ArtifactId

ArtifactId

simplepoller
Last Version

Last Version

0.0.1-alpha
Release Date

Release Date

Type

Type

pom.sha512
Description

Description

simplepoller
A dead simple polling implementation in kotlin coroutines and flow
Project URL

Project URL

https://github.com/CuriousNikhil/simplepoller
Source Code Management

Source Code Management

https://github.com/CuriousNikhil/simplepoller

Download simplepoller

Dependencies

runtime (2)

Group / Artifact Type Version
org.jetbrains.kotlin : kotlin-stdlib jar 1.5.0
org.jetbrains.kotlinx : kotlinx-coroutines-core-jvm jar 1.5.0-RC

Project Modules

There are no modules declared in this project.

simplepoller

A dead simple poller with kotlin coroutines and flow.

Add dependency

Add dependency to your app level build.gradle

dependencies {
    implementation 'me.nikhilchaudhari:simplepoller:0.0.1-alpha'
}

Usage

//build poller
val poller = Poller.Builder()
      .get(url = "<URL>")                 // get method and provide url
      .setIntervals(1000, 60000, 2, 2000) // set intervals base, max, delayfactor and delay 
                                          // (or you can use .setInfinitePoll(true) to poll infinitely with provided `delay` value)
      .setDispatcher(Dispatchers.Main)    // Set the dispatcher where you want your result of polling 
                                          // (Please add android/javafx/swing coroutines dependency before if you want to set the Main dispatcher)
      .onResponse {
          textview.text = it.text         // onResponse will be executed on each response received while polling
      }.onError {                        
          Log.e(TAG, it?.message)         // onError will be executed in case of any error
      }.build()                           // build the poller


// Start the poller
poller.start()


// Stop the poller
poller.stop()

Note: Documentation is in progress

Versions

Version
0.0.1-alpha