React.js - flux vs global event bus

前端 未结 4 1700
情书的邮戳
情书的邮戳 2021-02-15 01:45

What is the advantage of using Flux over a global event bus? I think the dispatcher is all that is needed:

  1. component publishes \'user event\' with data to the dis
4条回答
  •  [愿得一人]
    2021-02-15 01:59

    I think what others have said about application structure and the change event is important, but I should add this one thing:

    The dispatcher's waitFor method is the biggest difference between registering the stores with a dispatcher vs. the stores listening to a global event bus. This method lets you manage which stores update before others. And that becomes vital when you want StoreB to look first at what StoreA did before it decides what to do.

    You could think of the dispatcher as a global event bus with a waitFor method, and that would be somewhat accurate.

提交回复
热议问题