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

Reactive Programming Workshop

Reactive Programming Workshop

IIT Kharagpur - Kshitij 2018 - Workshop on "Reactive Programming in Java, Android, and Kotlin" by Rivu Chakraborty, GDG (Google Developers Group) Kolkata

Rivu Chakraborty

January 21, 2018
Tweet

More Decks by Rivu Chakraborty

Other Decks in Programming

Transcript

  1. Reactive Programming in Java, Android and Kotlin by Rivu Chakraborty

    Website: rivuchk.com, Twitter: @rivuchakraborty, LinkedIn: linkedin.com/in/rivuchk/, Github: @RivuChk Core Organising Team Member ‐ GDG ﴾Google Developers Group﴿ Kolkata Founder Organiser ‐ Kotlin Kolkata User Group Sr. Software Engineer ﴾Android﴿ ‐ Indus Net Technologies Pvt. Ltd. Author Multiple Kotlin Titles Instructor ‐ Caster.io
  2. Books by Rivu Chakraborty Reactive Programming in Kotlin Functional Kotlin

    ﴾Co‐Author ‐ Mario Arias﴿ Coroutines for Android Developers ﴾Co‐Author ‐ Ravindra Kumar﴿ *More to come
  3. Reactive Programming ‐ What is it? Reactive Programming is an

    asynchronous Programming Paradigm that revolves around data streams and the propagation of change. In simpler words, those programs which propagate all the changes that affected its data/data streams to all the interested parties ﴾such as end users, components and sub‐parts, and other programs that are somehow related﴿ are called reactive programs. Source ‐ Reactive Programming in Kotlin, Chapter ‐ 1, Page ‐ 9
  4. Reactive Programming ‐ How to apply? Frameworks to apply /reactive

    Programming with your preffered language ReactiveX ‐ Rx Extensions ﴾RxJava, RxKotlin, RxCpp, RxSwift, RxJs etc.﴿ ﴾Rx Extensions for almost all languages﴿ Reactor, Reactor‐Kotlin ﴾JVM Languages Only﴿ Bacon.js ﴾JavaScript Only﴿ Akka ﴾Java, Scala Only﴿ Vert.x ﴾JVM Languages Only﴿
  5. RxJava/RxKotlin ‐ What to Learn? Observables, Flowables ‐ Producers Observers,

    Subscribers ‐ Consumers Operators ‐ To perform various operations Schedulers ‐ Threading/Concurrency made easy
  6. Observables In RxJava Observables represent the Producer that produces the

    Data Streams Observable has an underlying computation that produces values that can be consumed by a consumer ﴾Observer﴿. The most important thing here is that the consumer ﴾Observer﴿ doesn't pull values, instead the consumer is notified by the producer itself whenever there's a change.
  7. Observers In RxJava Observers represent the Consumer that consumes the

    Data Streams Java observable1.subscribe(new Observer<Integer>() {...}); observable2.subscribe((item)‐>{System.out.println("Item "+item);}); Kotlin observable1.subscribe(object : Observer<Int>() {...}) observable2.subscribe { item ‐> println("Item " + item) }
  8. Operators In RxJava Operators are those who modify/filter/performs actions synchronously

    on the Data Streams while it flows from Producer to the Consumer Java observable1 .map((item)‐>item*2) .filter((item)‐>item<=10) Kotlin observable1 .map{item‐>item*2} .filter {item‐>item<=10}
  9. Schedulers Schedulers are responsible of concurrency in a RxJava/RxKotlin program.

    They helps the programmer to deal concurrency, context switching and all threading with ease. .subscribeOn(Schedulers.single()) .observeOn(Schedulers.trampoline())