Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Reaktivní programování

Reaktivní programování

Aleš Roubíček

April 27, 2013
Tweet

More Decks by Aleš Roubíček

Other Decks in Programming

Transcript

  1. Events var els = document.getElementsByTagName('*'); // Case 1 for (var

    i = 0; i < els.length; i++){ els[i].addEventListener("click", e => { /* do something */ }, false); } // Case 2 function processEvent(e){ /*do something*/ } for (var i = 0; i < els.length; i++){ els[i].addEventListener("click", processEvent, false); }
  2. Events var els = document.getElementsByTagName('*'); // Case 1 for (var

    i = 0; i < els.length; i++){ els[i].addEventListener("click", e => { /* do something */ }, false); } // Case 2 function processEvent(e){ /*do something*/ } for (var i = 0; i < els.length; i++){ els[i].addEventListener("click", processEvent, false); }
  3. Callback hell step1(value1 => { step2(value1, value2 => { step3(value2,

    value3 => { step4(value3, value4 => { // Do something with value4 }); }); }); });
  4. Promises Q.fcall(step1). then(step2). then(step3). then(step4). then(value4 => { // Do

    something with value4 }, error => { // Handle any error from step1 through step4 }). done();
  5. Observable sequences interface IObservable<T> { IDisposable Subscribe(IObserver<T> observer); } interface

    IObserver<T> { void OnNext(T value); void OnError(Exception ex); void OnComplete(); }
  6. Observable sequences interface IObservable<T> { IDisposable Subscribe(IObserver<T> observer); } interface

    IObserver<T> { void OnNext(T value); void OnError(Exception ex); void OnComplete(); }
  7. Observable sequences interface IObservable<T> { IDisposable Subscribe(IObserver<T> observer); } interface

    IObserver<T> { void OnNext(T value); void OnError(Exception ex); void OnComplete(); } var subscription = xs.Subscribe(x => { // process value }, ex => { // handle error }); subscription.Dispose();
  8. Rx

  9. Rx

  10. Rx

  11. Rx