Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

Breaking up with Rx

Slide 5

Slide 5 text

Breaking up with Rx Ian Rumac Software Architect @ Undabot

Slide 6

Slide 6 text

The story so far

Slide 7

Slide 7 text

What RxJava gives us:
 The Good Parts

Slide 8

Slide 8 text

What RxJava gives us:
 The Good Parts • Easy stream manipulation • Simple concurrency • Chained operators • Observing state changes • Combining operators

Slide 9

Slide 9 text

What RxJava gives us:
 The Good Parts • Easy stream manipulation • Simple concurrency • Chained operators • Observing state changes • Combining operators

Slide 10

Slide 10 text

And we subscribed({});

Slide 11

Slide 11 text

And all was good.

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

What RxJava gives us:
 The Bad Parts

Slide 20

Slide 20 text

• One library that spans across all layers
 (remember migrating?) • One library which you shape your code around • One paradigm you force everything into • One naming style • One extra layer of complexity • Code • Mental What RxJava gives us:
 The Bad Parts

Slide 21

Slide 21 text

• One library that spans across all layers
 (remember migrating?) • One library which you shape your code around • One paradigm you force everything into • One naming style • One extra layer of complexity • Code • Mental What RxJava gives us:
 The Bad Parts

Slide 22

Slide 22 text

The core

Slide 23

Slide 23 text

• Is your business logic wrapped in Rx? • Is your business logic a stream? 
 (not a stream of one ) • Why do you represent the core logic of your app with a stream if it isn’t one? The core

Slide 24

Slide 24 text

So, what can we do about it?

Slide 25

Slide 25 text

Replacing the operator magic

Slide 26

Slide 26 text

Replacing the operator magic • Collection extensions already in stdlib

Slide 27

Slide 27 text

Replacing the operator magic • Collection extensions already in stdlib

Slide 28

Slide 28 text

Replacing the operator magic • Collection extensions already in stdlib

Slide 29

Slide 29 text

Replacing the operator magic • Collection extensions already in stdlib • Easy to write your own

Slide 30

Slide 30 text

Replacing the operator magic • Collection extensions already in stdlib • Easy to write your own

Slide 31

Slide 31 text

Replacing the operator magic • Collection extensions already in stdlib • Easy to write your own

Slide 32

Slide 32 text

Replacing the operator magic • Collection extensions already in stdlib • Easy to write your own • Receiver lambdas

Slide 33

Slide 33 text

Replacing the operator magic • Collection extensions already in stdlib • Easy to write your own • Receiver lambdas

Slide 34

Slide 34 text

Replacing the operator magic • Collection extensions already in stdlib • Easy to write your own • Receiver lambdas

Slide 35

Slide 35 text

Replacing the operator magic • Collection extensions already in stdlib • Easy to write your own • Receiver lambdas

Slide 36

Slide 36 text

Observing state changes

Slide 37

Slide 37 text

Observing state changes • Observable delegate

Slide 38

Slide 38 text

Observing state changes • Observable delegate

Slide 39

Slide 39 text

Observing state changes • Observable delegate • Vetoable delegate

Slide 40

Slide 40 text

Observing state changes • Observable delegate • Vetoable delegate

Slide 41

Slide 41 text

Observing state changes • Observable delegate • Vetoable delegate

Slide 42

Slide 42 text

Observing state changes • Observable delegate • Vetoable delegate

Slide 43

Slide 43 text

Observing state changes • Observable delegate • Vetoable delegate • Simple

Slide 44

Slide 44 text

Observing state changes • Observable delegate • Vetoable delegate • Simple • Cover a lot of usecases

Slide 45

Slide 45 text

Observing state changes • Observable delegate • Vetoable delegate • Simple • Cover a lot of usecases

Slide 46

Slide 46 text

Observing state changes • Observable delegate • Vetoable delegate • Simple • Cover a lot of usecases

Slide 47

Slide 47 text

Coroutines

Slide 48

Slide 48 text

Coroutines • Language feature • Lightweight • Context(s) • Easy thread switching

Slide 49

Slide 49 text

Coroutines

Slide 50

Slide 50 text

So just tldr light threads?

Slide 51

Slide 51 text

Coroutines

Slide 52

Slide 52 text

Coroutines • Easy concurrency • Yield! • Nesting and composing • cancelChildren()

Slide 53

Slide 53 text

Composing & Combining • Easy • Human readable • Wrap it any way you want

Slide 54

Slide 54 text

No content

Slide 55

Slide 55 text

doOne doTwo

Slide 56

Slide 56 text

No content

Slide 57

Slide 57 text

doOne doTwo

Slide 58

Slide 58 text

No content

Slide 59

Slide 59 text

doOne doTwo

Slide 60

Slide 60 text

No content

Slide 61

Slide 61 text

No content

Slide 62

Slide 62 text

No content

Slide 63

Slide 63 text

No content

Slide 64

Slide 64 text

But wait, there’s more!

Slide 65

Slide 65 text

Channels 101

Slide 66

Slide 66 text

Channels 101 • A hot asynchronous stream of elements

Slide 67

Slide 67 text

Channels 101 • A hot asynchronous stream of elements • Rendezvous transfer

Slide 68

Slide 68 text

Channels 101 • A hot asynchronous stream of elements • Rendezvous transfer • Suspending

Slide 69

Slide 69 text

Channels 101 • A hot asynchronous stream of elements • Rendezvous transfer • Suspending • Once it’s consumed, it’s consumed

Slide 70

Slide 70 text

Channels 101 • A hot asynchronous stream of elements • Rendezvous transfer • Suspending • Once it’s consumed, it’s consumed • 1 item at a time

Slide 71

Slide 71 text

Channels 101

Slide 72

Slide 72 text

Channels 101

Slide 73

Slide 73 text

Channels 101

Slide 74

Slide 74 text

Channels 101

Slide 75

Slide 75 text

Channels 101

Slide 76

Slide 76 text

Channels 101

Slide 77

Slide 77 text

Channels of all shapes and sizes! • ArrayChannel - Buffered! • ConflatedChannel - Only the latest element • Ticker channel - Time based operations • BroadcastChannel & ArrayBroadcastChannel “Broadcast channel is a non-blocking primitive for communication between the sender and multiple receivers that subscribe for the elements using [open] function and unsubscribe using [SubscriptionReceiveChannel.close] function.” ReceiveChannel

Slide 78

Slide 78 text

No content

Slide 79

Slide 79 text

… well I still need my operators…

Slide 80

Slide 80 text

… well I still need my operators…

Slide 81

Slide 81 text

… well I still need my operators…

Slide 82

Slide 82 text

… well I still need my operators…

Slide 83

Slide 83 text

… well I still need my operators…

Slide 84

Slide 84 text

… well I still need my operators…

Slide 85

Slide 85 text

… well I still need my operators…

Slide 86

Slide 86 text

… well I still need my operators…

Slide 87

Slide 87 text

No content

Slide 88

Slide 88 text

…that’s all nice, but how do I test it?

Slide 89

Slide 89 text

…that’s all nice, but how do I test it? Just like any other code. (Context = Unconfined)

Slide 90

Slide 90 text

Thinking about dumping your old library?

Slide 91

Slide 91 text

Thinking about dumping your old library? • KotlinX Coroutines Rx 1&2 • Kotlin Coroutine (Experimental) Retrofit Adapter • Still experimental! • Wrap the boilerplate

Slide 92

Slide 92 text

Conclusion

Slide 93

Slide 93 text

Conclusion Kotlin > RxJava

Slide 94

Slide 94 text

Conclusion

Slide 95

Slide 95 text

Conclusion Q & A?

Slide 96

Slide 96 text

No content

Slide 97

Slide 97 text

Thank you for your time! Ian Rumac Software Architect @Undabot