bed-con 2016 - i have a stream - einsichten in reactive programming

Post on 06-Jan-2017

249 Views

Category:

Education

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Moin BED-Con!

@wps_de

wps_de

https://www.wps.de

Reactive may refer to:

Generally, capable of having a reaction (disambiguation)

-Wikipedia

Reactive programming is

a programming paradigm…

-Wikipedia

R1.1(V0[:sig]) => R0 R1.2(V0[:m x sig]) => R0 0 => i | m + 1 => j [W [ i < j -> [ R1.1(V0[i: m x sig]) => R0 | i + 1 => i ] ] ] END R1.3() => R0 'H';'e';'l';'l';'o';',';' ';'w';'o';'r';'l';'d';'!' => Z0[: m x sig] R1.2(Z0) => R0 END

OOP to me means

only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things.

-Alan Kay

OOP to me means

only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things.

-Alan Kay

Purely functional programming

is different. You don’t tell the computer what to do – you tell him what stuff is.

-Miran Lipovaca

Purely functional programming

is different. You don’t tell the computer what to do – you tell him what stuff is.

-Miran Lipovaca

fib 0 = 0fib 1 = 1fib n = fib (n-1) + fib (n-2)

𝑓1 = 𝑓2 = 1𝑓𝑛 = 𝑓𝑛−1 + 𝑓𝑛−2 für 𝑛 > 2

Reactive programming is

a programming paradigm oriented around data flows and the propagation of change.

-Wikipedia

[ 1, 1, 2, 3, 5, 8, 13 ]

.filter(x -> x%2 == 0)

[ 2, 8 ]

x=100 x=234 x=234 x=144 x=305

y=1 y=634 y=137 y=680 y=32[ , , , , ->

.filter(c -> c.x > 200)

y=634 y=137 y=32

x=234 x=234 x=305[ , , ->

http://reactivex.io/

Subscription s = Observable.just("Hello, world!")

.subscribe(new Subscriber<String>() {

@Override

public void onCompleted() {

// do sth

}

@Override

public void onError(Throwable e) {

// handle error stuff

}

@Override

public void onNext(String s) {

// next!

}

}

);

public class ColdExample {

public static void main(String[] args){

ArrayList<Integer> sampleList = new ArrayList<>();

for(int i = 0; i<5; i++){

sampleList.add(i);

}

Observable.from(sampleList)

.observeOn(Schedulers.computation())

.toBlocking()

.forEach(System.out::println);

}

}

public static Observable<Integer> hotStream() {

return Observable.create((Subscriber<? super Integer> s) -> {

int i = 0;

while (!s.isUnsubscribed()) {

s.onNext(i++);

try {

Thread.sleep((long) (Math.random() * 100));

} catch (Exception e) {

// do nothing

}

}

}).subscribeOn(Schedulers.newThread());

}

taken from https://github.com/jhusain/learnrxjava

http://reactivex.io/languages.html

Java

JavaScript

C#

C#(Unity)

Scala

Clojure

C++

Ruby

Python

Groovy

JRuby

Kotlin

Swift

http://reactivex.io/tutorials.html

2 minute introduction to Rx by André Staltz

A Playful Introduction to Rx a video lecture by Erik Meijer

http://rxmarbles.com/

top related