Presentation is loading. Please wait.

Presentation is loading. Please wait.

Reactive Android Development

Similar presentations


Presentation on theme: "Reactive Android Development"— Presentation transcript:

1 Reactive Android Development
CS T & CS T Summer 2016 Sodium FRP

2 Observer pattern Very common in GUIs
onClick More generally, can be applied to data structures Define an interface to deliver changes Override accessor methods to deliver changes

3 What could go wrong?

4 What could go wrong? A -> B B -> C C -> A

5 What else could go wrong?

6 What else could go wrong?
A -> B A -> C C -> D B -> D

7 What else else could go wrong?

8 What else else could go wrong?
Code ends up distributed

9 How does Sodium try to fix this
Cells provide the 'listener' behavior automatically

10 How does Sodium try to fix this
Cells provide the 'listener' behavior automatically Guaranteed update order Diamond dependencies are not a problem

11 How does Sodium try to fix this
Cells provide the 'listener' behavior automatically Guaranteed update order Diamond dependencies are not a problem Arguably nice tools for working with reactive values

12 Reactive values Cells Streams Hold a value at all time
Can register to be notified of changes Streams Represent a stream of ephemeral events Can register to be notified of events

13 Map Works for cells and streams
Creates a new cell/stream that is the result of applying a function to the input stream C.map((c)->2*c)

14 Lift C = A + B

15 Lift C = A + B A.lift(B,(a,b) -> a + b);

16 Snapshot Cell C Stream E E.snapshot(C,(e,c) -> f (e,c))

17 Merge Combines the events of two streams into a single stream.

18 Example Code GitHub kbaldor SodiumTest


Download ppt "Reactive Android Development"

Similar presentations


Ads by Google