Slide 1

Slide 1 text

Reactive programming (with video explanation) Krishantha Dinesh Msc, MIEEE, MBCS Software Architect www.krishantha.com www.youtube.com/krish @krishantha

Slide 2

Slide 2 text

Find the explaining video • This slides explain (prasentation) training can find below URL • https://youtu.be/iTv62Dq5Z 1w

Slide 3

Slide 3 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ What is it ? • Reactive programing is nothing but programming paradigm which is allow us to manupulate steams of data using functions. • Everything happens (mean to) asynchronusly. • Which mean we do some operation of streams of data which start from one place and being consumed at other place

Slide 4

Slide 4 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ keys Inorder to make reactive programming in reallity we need 3 things • Data as streams • Functional programing. (different from imperative programming) • Asynchronous observers. (part of the program execute in different timeline than others. Not a one line after other blocking execution)

Slide 5

Slide 5 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ What can do with it ? • Can be use anywhere where it take time to process the request. • As example calling rest API over http to fetch some data and fileter out result and populate on UI • Log notification / sensor data • Read data from datastore and do some processing on that before produce

Slide 6

Slide 6 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Descend to 35000 to 10000 ft 1 2 3 4 6 0 8 9 10 16 12 13 Filter (x => (x%2)==0 || (x%3)==0 ) 2 3 4 6 8 9 10 16 12 2 3 4 6 8 9 10 16 12 If function take time results can be shifted

Slide 7

Slide 7 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Who's who 1 2 3 4 6 0 8 9 10 16 12 13 2 3 4 6 8 9 10 16 12 Function use to manipulate the stream and process output Source (stream) who emit the data is call subject Entity who subscribed to the subject to consume the data call observer this can be 1 or multiple This use pub sub and call observer pattern. (https://en.wikipedia.org/wiki/Design_Patterns)

Slide 8

Slide 8 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Functions can be nested 1 2 3 4 6 0 8 9 10 16 12 13 2 3 4 6 8 9 10 16 12 10

Slide 9

Slide 9 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ What is functional programming • Most of developers starts with imperative programming. So moving in to functional programming from that paradigm is not easy. • Other way also same and it would be more harder. • So understanding difference is importsant.

Slide 10

Slide 10 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Imperative programming Functional programming Focus on how program works Focus on What is the objective (what to solve) Easy learning curve Can be long learning curve on migrations Functions, conditions, loops, and OOP concepts available Ideally to be stateless Statement can change state of the program Use functions to create expressions rather statements. We can use chains of functions Eg: Java , C Eg: scala If ( x%2==0 || x%3==0){ list.add(x); } var filetered=x=>{ return x%2==0 || x%3==0 }

Slide 11

Slide 11 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ What languages do support this ? Reactive programming is a concept / theory of problem solveing. Most of languages specially early languages like C, C++, Java do not have this feature in build with the language. Need to use external libraries to achive this over.

Slide 12

Slide 12 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Reactive programming reactivex.io RxJava RxJS Rx.Net RxScala

Slide 13

Slide 13 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Is functional programming new? • First functional programming language was LIPS by IBM in 1950s • But 1980 – 2000 nish Java and OOP was dominated the industry so function programing wasn’t taking off • But when Node and other java script based languages getting popular again functional programing is taking off its journey.