
Useful Rx Snippets #2
Just a few random and (probably) useful Rx snippets in kotlin.
Parallel Observables
Start n number of observables together, and get results of all as an array of responses.
Scenario → There are multiple network requests, that can be run independently, but these requests are to be considered as a single operation.
What the output is:

Single Debounce
Create a debounce effect but only for the first n seconds (or milliseconds).
Scenario → There’s a need to add a small delay between the time response is returned and the time it’s displayed on screen. For example, showing a loader for at least 500ms, if the response is retrieved before 500ms, hold it, and if not then immediately show it.
Infinite Stream with error handling
Handle errors and resume an observable in case of any errors.
What it prints out:

Scenario → Login Screen
You can also checkout Useful Rx Snippets #1 for more snippets.
Happy coding!