Reaktivní programování

Reaktivní programování

428a9c6e5b151e618d4db288105bc5f3?s=128

Aleš Roubíček

April 27, 2013
Tweet

Transcript

  1. 2.
  2. 3.

    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. 4.

    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); }
  4. 5.

    Callback hell step1(value1 => { step2(value1, value2 => { step3(value2,

    value3 => { step4(value3, value4 => { // Do something with value4 }); }); }); });
  5. 7.

    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();
  6. 10.

    Observable sequences interface IObservable<T> { IDisposable Subscribe(IObserver<T> observer); } interface

    IObserver<T> { void OnNext(T value); void OnError(Exception ex); void OnComplete(); }
  7. 11.

    Observable sequences interface IObservable<T> { IDisposable Subscribe(IObserver<T> observer); } interface

    IObserver<T> { void OnNext(T value); void OnError(Exception ex); void OnComplete(); }
  8. 12.

    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();
  9. 14.

    Rx

  10. 15.

    Rx

  11. 16.

    Rx

  12. 17.

    Rx