Data Flow

it2022-05-09  64

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

转载于:https://www.cnblogs.com/lun8115/p/5816134.html


最新回复(0)