1 of 73

Exploring the possibilities of Unidirectional Data Flow Architectures on Android

Brian Egan & Guillaume Lung

November 10, 2015

2 of 73

Danger: Fun & Experimental!

We don’t actually use any of this on the SoundCloud Android App.

3 of 73

4 of 73

What’s happening?

UI

Playback

User Interaction

ZOMG

5 of 73

Visualize the state change!

State

UI

State

UI

State

UI

State

UI

6 of 73

Demo Redux, Brian!

7 of 73

DX

8 of 73

The Basics

9 of 73

f( )

Unidirectional Flow

State

UI

Actions / Intent

10 of 73

Global State

State

Immutable Data Structures

11 of 73

A simple counter app.

One example to try them all.

12 of 73

13 of 73

14 of 73

15 of 73

16 of 73

17 of 73

Plan

  1. State with Redux
  2. Components with Elm
  3. RX with Cycle

18 of 73

Redux

19 of 73

Data Flow in Redux

model

reduce

model

action

,

state change notification

Subscriber

20 of 73

21 of 73

22 of 73

23 of 73

24 of 73

25 of 73

26 of 73

27 of 73

28 of 73

State & UI Over time

State

UI

State

UI

State

UI

State

UI

29 of 73

Time Travel!

State

UI

State

UI

State

UI

State

UI

30 of 73

Time Travel!

State

UI

State

UI

State

UI

State

UI

31 of 73

Time Travel!

State

UI

State

UI

State

UI

State

UI

32 of 73

Time Travel!

State

UI

State

UI

State

UI

State

UI

33 of 73

Testing!

34 of 73

Elm Architecture

35 of 73

Elm Architecture

update

model

view

36 of 73

Elm Architecture

update

model

view

UI

37 of 73

Elm Architecture

update

model

view

UI

action

38 of 73

Elm Architecture

model

update

model

view

UI

action

,

39 of 73

40 of 73

41 of 73

42 of 73

43 of 73

44 of 73

Composable

action

model

update

view

45 of 73

Components

action

model

update

view

46 of 73

Compose interfaces with Components!

47 of 73

Open / Closed principle

48 of 73

Views become testable

update

model

view

View

Data

Structure

49 of 73

Cycle.js

50 of 73

Cycle

driver

main

51 of 73

Cycle

View

View

View

driver

main

Itent

Itent

Itent

52 of 73

53 of 73

54 of 73

55 of 73

56 of 73

57 of 73

58 of 73

59 of 73

Complex.

60 of 73

Render anywhere!

State

Android

State

iOS

State

web

State

Server

61 of 73

Now for the Android Demo!

A TODO list with redux and debug tools

62 of 73

Wrapping up

63 of 73

f( )

Unidirectional Flow

State

UI

Actions

64 of 73

Benefits

Composable UI

Time Travel Debugging

Testing

Render anywhere

Fun to learn :)

65 of 73

More possibilities

Bug reports, Databases, Hot Reloading*

66 of 73

Unsolved

Memory Footprint, UI Rendering Speed

67 of 73

Should I start writing my production apps like this?

68 of 73

NO

69 of 73

Should we continue to experiment and improve our architectures?

70 of 73

YES

71 of 73

Pleasure in development

72 of 73

Thank you.

Brian Egan & Guillaume Lung

December 10, 2015

73 of 73

Resources