volt volta quo quo vadi vadis s erik meijer
play

Volt Volta Quo Quo Vadi Vadis? s? Erik Meijer Wes Dyer - PowerPoint PPT Presentation

Volt Volta Quo Quo Vadi Vadis? s? Erik Meijer Wes Dyer Jeffrey van Gogh Bart de Smet Matthew Podwysocki Fu Fundam damentally entally ch chan ange ge th the way e way yo you th think ink ab abou out t co coor ordin


  1. Volt Volta Quo Quo Vadi Vadis? s?

  2. Erik Meijer Wes Dyer Jeffrey van Gogh Bart de Smet Matthew Podwysocki

  3. Fu Fundam damentally entally ch chan ange ge th the way e way yo you th think ink ab abou out t co coor ordin dinating ating an and d hat? What? orch or chestrating estrating as asyn ynchrono chronous us an and d eve event nt-based based pro rogramming ramming

  4. Be Beca cause use th the e es esse senc nce e of of Clo loud, d, hy? Web, Web , Mo Mobi bile le is is Why? as asyn ynchrono chronous us co comp mputation utations s

  5. By By sho showing wing th that at as asyn ynchrono chronous us an and d eve event-based based w? How? co comp mputation utations s ar are e ju just st push sh-based based co colle llect ctions ions

  6. An And d yo you ha u have ve th the e chan ch ance ce to to win win so some me $$ $$$

  7. Envir vironment onment 1 2 Progr gram am 2 1 Rea eactiv ctive Interact teractiv ive Program Environment in control in control

  8. A co A conc ncrete rete co collection lection of of po poke ker r co coins ns enumerable observable collection collection implements interface interface

  9. Enumerable collections interface IEnumerable<out T> { IEnumerator<T> GetEnumerator() } interface IEnumerator<out T>: IDisposable { bool MoveNext() T Current{ get; } // throws Exception }

  10. Enu numera merable ble co colle llection ction of ch f chips ips 1 GetEnumerator() 2 MoveNext() Consumer Current pu pull lls successive 3 true/false elements from The collection

  11. Ob Obse servabl rvable e co colle llection ction of ch f chips ps 1 Subscribe 2 OnNext 3 Producer OnCompleted() pushe pu hes successive elements from The collection

  12. Dua uality lity in n Mat ath h an and Eng ngineer ineering ing !(p||q) == (!p)&&(!q) !(p&&q) == (!p)||(!q)

  13. Dua uality lity in n Mat ath h an and Eng ngineering ineering 1/R = 1/ R 1 +…+1/ R n R = R 1 +…+ R n 1/C = 1/ C 1 +…+1/ C n C = C 1 +…+ C n

  14. Dua uality lity in n Mat ath h an and Eng ngineering ineering

  15. Dualize Enumerable collections interface IEnumerable<out T> { IEnumerator<T> GetEnumerator() } interface IObservable<out T> { IDisposable Subscribe(IObserver<T> o) }

  16. Dualize Enumerable collections interface IEnumerator<out T> { bool MoveNext() // throws Exception T Current{ get; } } interface IObserver<in T> { void OnCompleted(bool done) T OnNext{ set; } void OnError(Exception e) }

  17. Observable collections interface IObservable<out T> { IDisposable Subscribe(IObserver<T> o) } interface IObserver<in T> { void OnDone(bool done) T OnNext{ set; } void OnError(Exception e) }

  18. Observable collections interface IObservable<out T> { IDisposable Subscribe(IObserver<T> o) } interface IObserver<in T> { void OnCompleted() void OnNext(T value) void OnError(Exception e) }

  19. Iterator intimately related Subject Observer

  20. Ja Java a It Iterable rable & It & Itera erator tor Observ Ob ervable able/Observer /Observer class Observable interface Iterable<T> { { void addObserver(Observer o); Iterator<T> iterator() void deleteObserver(Observer o); void deleteObservers(); int countObservers(); void notifyObservers(); void notifyObservers(Object arg); void setChanged(); void clearChanged(); boolean hasChanged(); } } public interface Observer interface Iterator<T> { { void update(Observable o, Object arg); T next() // throws NoSuchElementException boolean hasNext() void remove() } }

  21. IEnume umerab rable/ le/IEn IEnume umerat rator or pro roto toty typical pical inte terf rface ace for r inte teractiv ractive e colle lectio ctions ns and inte teractiv ractive e pro rogra rams ms er IObserv servable able/IOb /IObserv server pro roto toty typical pical inte terf rface ace for r ob obse serv rvable able co colle lections ctions an and d re reactiv tive, e, asynch nchro ronou nous s & & ev even ent-ba based sed pro rogra rams ms

  22. Bu Buy y en enumera umerable ble co coll llection ections ge get t ob observa servable ble co coll llections ections for or fre ree! e! Both Bo th co collection llection in inte terfaces rfaces su supp pport ort th the e LI LINQ NQ St Standar andard d Qu Quer ery y Oper perators ators

  23. Sa Samp mples les Drag and Drop Dictionary Suggest (AJAX programming using LINQ queries ) Clock (MVC programming using LINQ queries ) Twitter on Bing maps Animation

  24. Combines event Di Dict ctionary onary Sug Suggest gest in n stream from UI with async C# C# call across network Html Format(this string [] entries) {…} [RunAtOrigin()] IObservable<string[]> Suggest (this Dictionary dict, string prefix, int count) {…} var inputValues = from i in Input.GetKeyUp() select i.Value; var q = from s in inputValues from r in Dictionary.Suggest(s, 10) select r.Format(); q.Subscribe(html => { output.InnerHtml = html; });

  25. r ra ray ⊑ r ray ra ⊒

  26. Pree eemp mption tion ope perator ator (Este stere relle) lle) var q = from s in inputValues from r in Dictionary.Suggest(s, 10) select r.Format(); var q = inputValues.Throttle(500). Publish(_inputValues => from s in _inputValues from r in Dictionary.Suggest(s, 10) .TakeUntil(_inputValues) select r.Format());

  27. In Ja In JavaS aScript cript var input = document.getElementById("input"); var results = document.getElementById("results"); var changed = Rx.Observable.FromHtmlEvent(input, "keyup") .Select(function(){ return input.value }) .Where(function(value){ return value != ""; });

  28. Switch Sw itch ins nste tead ad of Que f Query ry Sy Synt ntax ax changed.Throttle(250) .Select(function(what) { return query(what); }) .Switch() .Select(function(results) { return formatAsHtml(results); }) .Subscribe(function(html) { results.innerHTML = html; }, function(error){ results.innerHTML = "&gt;error retrieving results&lt;"; });

  29. Twitte itter r on Bi n Bing ngMa Maps ps

  30. JQ JQue uery ry Bindi nding ng jQuery.fn.ToObservable = function(eventType, eventData) { return Rx.Observable .FromJQuery(this, eventType, eventData); } Rx.Observable.FromJQueryEvent(someJQueryObject, “mousemove”)  someJQueryObject.ToObservable(“mousemove”) Array.prototype.toObservable = function() { return Rx.Observable.FromArray(this); };

  31. Same pa Sa patter tern n as as di dictionary ctionary sug ugge gest st Rx.Observable.Interval(10000) .Select(function() { return searchTwitter("#mix10"); }) .Switch() .Select(function(result) { return JSON.parse(result.responseText); }) .SelectMany(function(data) { return data.results.toObservable(); }) .Where(function(data) { return data.geo != null; }) .Subscribe( function(data) { var lat = data.geo.coordinates[0]; var lon = data.geo.coordinates[1]; addPushPin(map, data.id, data.created_at, lat, lon, data.profile_image_url, data.from_user, data.text); }, function(error) { alert(error); }); });

  32. Drag ag & Dr Drop p On On Wind ndow ows s Phone hone 7 dX dY

  33. The e code e … var W = … control to be dragged …; var mouseDowns = from md in W.GetMouseDown() select true; var mouseUps = from mu in W.GetMouseUp() select false; var mouseClicks = mouseDowns.Merge(mouseUps); var mouseMoves = from mm in W.GetMouseMove() select new{ mm.X, mm.Y }; var mouseDiffs = from diff in mouseMoves.Skip(1).Zip(mouseMoves) select new { dX = diff.First.X – diff.Second.X , dY = diff.First.Y – diff.Second.Y }; var mouseDrag = from leftdown in mouseClicks from delta in mouseDiffs where leftdown select delta; mouseDrag.Subscribe(delta => { … move W by delta … });

  34. Si Side de-Effects Effects var mouseDiffs = from diff in mouseMoves.Skip(1).Zip(mouseMoves) select new { dX = diff.First.X – diff.Second.X , dY = diff.First.Y – diff.Second.Y }; var mouseDiffs = mouseMoves.Let(_mousemoves => from diff in _mouseMoves.Skip(1).Zip(_mouseMoves) select new { dX = diff.First.X – diff.Second.X , dY = diff.First.Y – diff.Second.Y });

  35. MVC MVC IObserver IObservable Model del View ew

  36. function startClock() { var timeModel = getTime(); var analogView = getAnalogClock(); timeModel.Subscribe(analogView); }

  37. Th The Mod e Model el function getTime() { return Rx.Observable.Interval(100) .Select(function() { var date = new Date(); var result = { hours : date.getHours(), minutes : date.getMinutes(), seconds : date.getSeconds(), }; return result; }); }

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend