Functional Reactive Programming


Details
In the first Functional Brighton of 2016, FB regular Darran Eteo will give us an introduction to Functional Reactive Programming and RxJava:
Ever wondered what all the fuss was about with Functional Reactive Programming and why it is so cool? The next talk will give a quick overview of this area, covering objects, operators and a quick example to tie everything together.
We will cover:
-
Observers. An object that watches and interacts with a stream.
-
Observables. A key part of reactive which allows you to "emit" values as a stream.
-
Subjects. Which can act as both an Observable and an Observer.
We will discuss how the above can be chained to together, and can be used produce elegant solutions to particular problems. This can be done with ease, even in a multi-threaded environment, with call-backs, which as we all know can be challenging.
Some of the operators which will be examined:
-
subscribe/onSubscribe/onNext/onError/onComplete. Used to control the flow of your data as it streams through the Observables.
-
create/just/map/flatmap/take etc. Commands we can chain together to achieve our aims.
-
observeOn/subscribeOn. Tells the system which thread to run the code on. We can observe on one thread (i.e. do the heavy work on), then pass the results to another thread(one that interacts with the UI which are usually single-threaded)
-
Schedulers. Look at different type of Schedulers. How schedulers can be used to simplify threading models (If we do all our db work on one thread, no need for locks, this can be done with a scheduler that contains a single worker thread).
There are many of these operators, and I will cover the important ones, and try to give some idea of how they can be used and interact.
Finally I will give a (hopefully) elegant example, which would be rather hard to create normally. This example would require lots of code, using conventional programming techniques, but can be expressed using a just few lines of java code. Hopefully all this will help you to begin to start thinking in a Rx way.

Functional Reactive Programming