Useful Rx Snippets #1

Ahmed Rizwan
AndroidPub

--

Just a few random and probably useful snippets of Rx (in kotlin)

A timer

Yep, just a simple timer, that runs for 5 seconds.

Retry network call

In case of a failure, retry a network call or any long running process (in this example three times), and each time increasing the delay. (explanation)

Chaining requests

Chain requests or long running processes.

Polling requests

Poll requests until a certain condition becomes true.

Get initials

Get initials from a list of names.

Get RecyclerView visible items (RxAndroid)

With a slight delay, after user’s done scrolling, get all the visible items from RecyclerView (using RxBinding).

Until next time, that’s it for now! Happy coding!

Some references: Dan Lew’s post on Retry vs Repeat, A post on long polling, RxBinding, RxKotlin

--

--

AndroidPub
AndroidPub

Published in AndroidPub

The (retired) Pub(lication) for Android & Tech, focused on Development

Ahmed Rizwan
Ahmed Rizwan

Written by Ahmed Rizwan

Web | Android | Senior Software Engineer @QuixelTools