Data Flow

Data Flow

  两种实现:

    Flux

    Reflux

  Flux

    the dispatcher

    the stores

    the views

    the actions

    整个流程如下:
      • 首先要有 action,通过定义一些action creator 方法根据需要创建 Action 提供给 dispatcher
      • View 层通过用户交互会触发 Action
      • Dispatcher 会分发触发的 Action 给所有注册的 Store 的回调函数
      • Store 回调函数根据接收的 Action 更新自身数据之后会触发一个change 事件通知 View 数据更改了
      • View 会监听这个change 事件,拿到对应的新数据并调用setState 更新组件 UI

posted @ 2016-08-28 22:00  小宝贝来qin一个  阅读(166)  评论(0编辑  收藏  举报