Parabola对《Functional Reactive Programming》的笔记(1)

Functional Reactive Programming
  • 书名: Functional Reactive Programming
  • 作者: Stephen Blackheath/Anthony Jones
  • 页数: 245
  • 出版社: Manning Publications
  • 出版年: 2016-2-28
  • Appendix B

    "The six plagues of event handling" 终于有非常贴切的总结了,全是经验的血泪,还带有生动的例子。A good example is better than thousands of words.

    My notes / comments:

    1. unpredictable order - event arrival depends on register order - cannot merge / remove events by types within one transaction 2. missed first event - depends on if the emitter is synchronouns / asynchronouns 3. messy state - "network connection succeeds or fails synchronously", etc. - chaos - you have to write your handlers, using sync calls only, or just write callbacks for all APIs even they're as simple as a+b 4. threading issues - just think about the facebook notification bug, and how it's resolved by the react / flux architecture - the answer is immutable state sharing: "Threads are defined as multiple independent execution streams, shared mutable state, preemptive scheduling, synchronization. But wait a minute! What if there’s no shared state? Then there’s no synchronization, either. Threads don’t look so bad after all. Is shared state so deeply rooted in our belief system that we blame threads, when shared mutable state is the real culprit? We think so." 5. leaking callbacks - forgot to unregister listeners. it's easy to understand 6. accidental recursion - met this issue several times before. it's hard to determine if there's an event loop within the big and complex, full-of-conditions state machine. any unconsidered cases will probably cause deadlocks

    2017-08-31 20:43:11 回应