End to End Reac+ve Programming at Ne3lix Who am I? - - PowerPoint PPT Presentation

end to end reac ve programming at ne3lix who am i
SMART_READER_LITE
LIVE PREVIEW

End to End Reac+ve Programming at Ne3lix Who am I? - - PowerPoint PPT Presentation

End to End Reac+ve Programming at Ne3lix Who am I? Technical Lead for all the Ne3lix UIs 12 years in the industry, formerly worked at


slide-1
SLIDE 1

End ¡to ¡End ¡Reac+ve ¡ Programming ¡at ¡Ne3lix ¡

slide-2
SLIDE 2

Who ¡am ¡I? ¡

  • Technical ¡Lead ¡for ¡all ¡the ¡Ne3lix ¡UI’s ¡
  • 12 ¡years ¡in ¡the ¡industry, ¡formerly ¡worked ¡at ¡

GE ¡and ¡MicrosoI ¡

  • 4 ¡years ¡of ¡experience ¡building ¡systems ¡with ¡

Func+onal ¡Reac+ve ¡Programming ¡ ¡

slide-3
SLIDE 3

Rewind ¡Two ¡Years ¡

Ne3lix ¡had ¡decided ¡to ¡change ¡our ¡client-­‑server ¡ interac+on ¡model. ¡

slide-4
SLIDE 4

Before ¡

All ¡UI’s ¡used ¡the ¡same ¡endpoints. ¡

hSp://ne3lix.com/api ¡

slide-5
SLIDE 5

Problems ¡

  • Tight ¡coupling ¡between ¡Middle ¡Tier ¡and ¡UI ¡

teams ¡

  • One-­‑sized ¡fits ¡all ¡messages ¡
  • Inefficient ¡call ¡paSerns ¡
slide-6
SLIDE 6

The ¡Plan ¡

Give ¡UI ¡developers ¡the ¡ability ¡to ¡create ¡ endpoints ¡specialized ¡for ¡their ¡devices. ¡

hSp://ne3lix.com/xbox ¡ hSp://ne3lix.com/ps3 ¡ hSp://ne3lix.com/wii ¡ hSp://ne3lix.com/mobile ¡

slide-7
SLIDE 7

Some ¡UI ¡developers ¡saw ¡it ¡this ¡way… ¡

hSp://ne3lix.com/xbox ¡ hSp://ne3lix.com/ps3 ¡ hSp://ne3lix.com/wii ¡ hSp://ne3lix.com/mobile ¡

Give ¡Force ¡UI ¡developers ¡the ¡ability ¡to ¡create ¡ endpoints ¡specialized ¡for ¡their ¡devices. ¡

slide-8
SLIDE 8

Two ¡Developer ¡Personas ¡

Cloud ¡ UI ¡

slide-9
SLIDE 9

Challenge ¡

How ¡to ¡turn ¡UI ¡developers ¡into ¡effec+ve ¡cloud ¡ developers? ¡

slide-10
SLIDE 10

Comforts ¡for ¡UI ¡Developers ¡

  • Groovy ¡
  • OO ¡API ¡
  • Reac+ve ¡API ¡
slide-11
SLIDE 11

Reac+ve ¡is ¡Not ¡Enough ¡

  • Parallelism ¡+ ¡Aggrega+on ¡== ¡Conten+on ¡
  • Most ¡UI ¡developers ¡can’t ¡be ¡trusted ¡with ¡locks ¡
slide-12
SLIDE 12

How ¡to ¡make ¡parallel ¡programming ¡safe ¡for ¡UI ¡ developers? ¡

slide-13
SLIDE 13

Rewind ¡Another ¡2 ¡Years ¡

slide-14
SLIDE 14

Erik ¡Meijer ¡

slide-15
SLIDE 15

“What’s ¡the ¡difference ¡between ¡a ¡database ¡ query… ¡

slide-16
SLIDE 16

…and ¡a ¡mouse ¡drag ¡event?” ¡

slide-17
SLIDE 17

“Nothing. ¡They ¡are ¡both ¡collec+ons.” ¡

slide-18
SLIDE 18

New ¡JS ¡Closure ¡syntax ¡

ES5 var add = function(x,y) { return x + y; } ES6 var add = (x,y) => x + y

slide-19
SLIDE 19

Query ¡for ¡well-­‑rated ¡Movies ¡

var getTopRatedFilms = user => user.videoLists. map(videoList => videoList.videos. filter(video => video.rating === 5.0)). flatten(); getTopRatedFilms(user). forEach(film => console.log(film));

slide-20
SLIDE 20

Mouse ¡Drag ¡Event ¡

var getElementDrags = elmt => elmt.mouseDowns. map(mouseDown => document.mouseMoves. filter takeUntil(document.mouseUps)). flatten(); getElementDrags(image). forEach(pos => image.position = pos);

slide-21
SLIDE 21
slide-22
SLIDE 22

Iterator<T> ¡ Observer<T> ¡

T ¡next() ¡ boolean ¡hasNext() ¡ throw ¡new ¡Throwable() ¡ void ¡onNext(T) ¡ void ¡onCompleted() ¡ ¡void ¡onError(Throwable) ¡

Iterable<T> ¡

Iterator<T> ¡iterator() ¡

Observable<T> ¡

subscribe(Observer<T>) ¡

Disposable ¡

¡void ¡dispose() ¡ ¡void ¡dispose() ¡

: ¡Disposable ¡

Disposable ¡

slide-23
SLIDE 23

Observable ¡and ¡Iterable ¡are ¡dual! ¡

slide-24
SLIDE 24

Reac+ve ¡Extensions ¡

  • Combinator ¡Library ¡for ¡Observable ¡type ¡
  • Open ¡Source ¡
  • Ported ¡to ¡

– C ¡ – C#/VB.Net ¡ – Javascript ¡ – Java ¡(Ne3lix) ¡

slide-25
SLIDE 25

Observable ¡Monad ¡

  • Vector ¡version ¡of ¡Con+nua+on ¡monad ¡
  • Null ¡propaga+on ¡seman+cs ¡of ¡Maybe ¡monad ¡
  • Error ¡propaga+on ¡seman+cs ¡of ¡Either ¡monad ¡
slide-26
SLIDE 26

Observable ¡Monad ¡(cont.) ¡

  • Produced ¡and ¡consumed ¡with ¡side-­‑effects ¡
  • Composed ¡func+onally ¡
  • Cancella+on ¡seman+cs ¡
  • Can ¡be ¡synchronous ¡or ¡asynchronous ¡
slide-27
SLIDE 27

Observable ¡Monad ¡(cont.) ¡

Cleanly ¡abstract ¡over ¡IO ¡streams ¡and ¡UI ¡events. ¡

slide-28
SLIDE 28

Map ¡over ¡Observable ¡

var map = (observable, func) => { forEach: observer => { var subscription =

  • bservable.forEach({
  • nNext: item => observer.onNext(func(item)),
  • nError: error => observer.onError(error),
  • nCompleted: () => observer.onCompleted()

}); return subscription; } };

slide-29
SLIDE 29

Three ¡Types ¡of ¡Composi+on ¡

var map = (observable, func) => { forEach: observer => { var subscription =

  • bservable.forEach({
  • nNext: item => observer.onNext(func(item)),
  • nError: error => observer.onError(error),
  • nCompleted: () => observer.onCompleted()

}); return subscription; } };

Observable ¡ Observer ¡ Subscrip+on ¡

slide-30
SLIDE 30

One ¡reac+ve ¡type ¡for ¡cloud ¡and ¡UI ¡developers. ¡

¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡bservable<T> ¡

slide-31
SLIDE 31

Social ¡No+fica+ons ¡on ¡Middle ¡Tier ¡

Observable.join( socialService.getFriends(user), messageService. getNotifications(). filter(notification => notification.video.isAvailable), friend => friend.id, // join key selector notification => notification.friend.id, // join key selector (friend, notification) => { id: notification.id, name: notification.video.name, message: notification.message, friend: { name: friend.name, id: friend.id } });

slide-32
SLIDE 32

Search ¡Auto-­‑complete ¡on ¡the ¡UI ¡

var searchResultSets = keyPresses. throttle(20). flatMap(search => getSearchResults(search). takeUntil(keyPresses)); searchResultSets.forEach( resultSet => listBox.setItems(resultSet));

slide-33
SLIDE 33

Composi+on ¡(map/filter) ¡ Read ¡from ¡InputStream ¡ Write ¡to ¡OuputStream ¡ Middle ¡Tier ¡ Data ¡Tier ¡ Composi+on ¡(map/filter) ¡ UI ¡ Impure ¡ Pure ¡ Composi+on ¡(map/filter) ¡ Composi+on ¡(map/filter) ¡

slide-34
SLIDE 34

Wins ¡

  • Got ¡Rx ¡Open-­‑sourced ¡
  • Ported ¡Observable ¡combinators ¡to ¡Java ¡

(RxJava) ¡

  • Currently ¡using ¡FRP ¡on ¡3 ¡different ¡pla3orms ¡
  • Large ¡sec+ons ¡of ¡UI ¡now ¡wriSen ¡in ¡FRP-­‑style ¡
  • Growing ¡awareness ¡of ¡and ¡competency ¡in ¡

func+onal ¡programming ¡in ¡general ¡

slide-35
SLIDE 35

Challenges ¡

  • Evangelism ¡
  • Training ¡
  • Performance ¡

¡

slide-36
SLIDE 36

Challenges: ¡Evangelism ¡

  • Don’t ¡assume ¡best ¡technical ¡solu+on ¡will ¡win ¡
  • Prac+ce ¡public ¡speaking ¡
  • Focus ¡on ¡the ¡soI ¡skills ¡

¡

slide-37
SLIDE 37

Challenges: ¡Training/Hiring ¡

  • Be ¡available ¡for ¡support ¡24/7 ¡
  • Teach ¡at ¡the ¡same ¡+me ¡

– Func+onal ¡Programming, ¡ ¡ – Vector ¡Programming ¡ – Reac+ve ¡Programming ¡

  • Look ¡outside ¡UI ¡teams ¡for ¡FP ¡competence ¡
  • bind/flatMap/concatMap/mapcat/mapMany ¡
  • Interac+ve ¡training ¡exercises ¡
  • Understanding ¡where ¡to ¡apply ¡FRP ¡on ¡the ¡client ¡

¡

slide-38
SLIDE 38

Challenges: ¡Performance ¡

  • Chunking ¡for ¡low-­‑end ¡devices ¡
  • Best ¡applied ¡to ¡less ¡chaSy ¡event ¡streams ¡
  • Decomposi+on ¡to ¡reduce ¡per-­‑item ¡cost ¡
  • Type-­‑unsafe ¡flatMap ¡easier ¡to ¡understand ¡and ¡

faster ¡

slide-39
SLIDE 39

Resources ¡

  • hSps://github.com/Reac+ve-­‑Extensions/RxJS ¡
  • hSp://jhusain.github.io/learnrx/ ¡
slide-40
SLIDE 40

Ques+ons ¡