rx2timer

General

Category
Free
Tag
FRP
License
MIT License
Min SDK
9 (Android 2.3–2.3.2 Gingerbread)
Registered
Apr 18, 2017
Favorites
1
Link
https://github.com/thepacific/timer
See also
RxRelay
Android-RxJava
RxState
RxJava2Interop
Rx.Observe

Additional

Language
Java
Version
1.0.0 (Aug 13, 2020)
Created
Feb 27, 2017
Updated
Aug 13, 2020
Owner
thepacific
Contributor
UsherBaby
1
Activity
Badge
Generate
Download
Source code
APK file

Commercial

This is a simple rxjava2/rxjava3/kotlin-flow timer. I copy this class into all the little apps I make. I'm tired of doing it. Now it's a library

Usage

timer = Rx2Timer.builder()
                .initialDelay(0) //default is 0
                .period(1) //default is 1
                .take(30) //default is 60
                .unit(TimeUnit.SECONDS) // default is TimeUnit.SECONDS
                .onEmit(count -> {
                    if (count < 10) {
                        binding.text.setText("0" + count + " s");
                    } else {
                        binding.text.setText(count + " s");
                    }
                })
                .onError(e -> binding.text.setText(R.string.count))
                .onComplete(() -> binding.text.setText(R.string.count))
                .build();

timer.start();
timer.stop();
timer.restart();
timer.pause();
timer.resume();
                

Gradle

// rxjava2
implementation 'com.github.thepacific:rx2-timer:1.0.0'
// rxjava3
implementation 'com.github.thepacific:rx3-timer:1.0.0'

License

The MIT License