Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Getting your feet wet with RxJava

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.

Getting your feet wet with RxJava

Presented in Feb '18 at JUG NCR Meetup, New Delhi.
https://www.meetup.com/Delhi-NCR-JUG/events/245487927/

Avatar for Ragunath Jawahar

Ragunath Jawahar

February 17, 2018
Tweet

More Decks by Ragunath Jawahar

Other Decks in Programming

Transcript

  1. FUNCTIONAL • Functions are first-class citizens • Immutability • No

    side-effects • Referential transparency • Declarative • Favours concurrency
  2. REACTIVE • Speed Traps • Fire Alarms • Airbags •

    Autonomous Vehicles • Excel • GUI Systems • Hystrix Real World Examples
  3. login(“username", “password", new Callback() { public void onSuccess(String authToken) {

    // Do something... } public void onFailure(Exception e) { // Show error message... } });
  4. Where is it used? • Back-end to build highly scalable

    systems. • Front-end to create maintainable code.
  5. Primitive - Observable • Produces events • Usually lazy •

    Can produce one, many or zero events •Serialized access
  6. button .setOnClickListener(click -> api.authenticate(username, password, new Callback() { public void

    onSuccess(String authToken) { // Save Token } public void onLoginFailed(LoginException e) { // Show Error } }) ); Callback
  7. button .setOnClickListener(click -> api.authenticate(username, password, new Callback() { public void

    onSuccess(String authToken) { // Save Token } public void onLoginFailed(LoginException e) { // Show Error } }) ); Callback
  8. button .setOnClickListener(click -> api.authenticate(username, password, new Callback() { public void

    onSuccess(String authToken) { // Save Token } public void onLoginFailed(LoginException e) { // Show Error } }) ); Callback
  9. button .setOnClickListener(click -> api.authenticate(username, password, new Callback() { public void

    onSuccess(String authToken) { // Save Token } public void onLoginFailed(LoginException e) { // Show Error } }) ); Callback
  10. button .setOnClickListener(click -> api.authenticate(username, password, new Callback() { public void

    onSuccess(String authToken) { // Save Token } public void onLoginFailed(LoginException e) { // Show Error } }) ); Callback
  11. button .setOnClickListener(click -> api.authenticate(username, password, new Callback() { public void

    onSuccess(String authToken) { // Save Token } public void onLoginFailed(LoginException e) { // Show Error } }) ); Callback
  12. RxJava - Operators • Single Observable • Multiple Observable •

    Higher-Order Observables •Finite and infinite Observables (any of the above)
  13. map

  14. amb

  15. zip

  16. Debugging • Could be a pain  • Use doOn*

    operators to inspect the pipeline • Traceur (RxJava 2)