Flux架构中的调度器、存储与视图组件解析
1. 调度器的实现
在Flux架构中,调度器是一个关键组件。与Facebook参考实现不同,这里的调度器是一个简单的模块,暴露了几个函数,包括 dispatch() 和 register() 。
-
dispatch()函数 :
// Used by action creator functions to dispatch an
// action payload.
export function dispatch(payload) {
// The dispatcher is busy, meaning that we've
// called "dispatch()" while an update round
// was already taking place.
if (busy) {
throw 'Nested dispatch() call detected';
}
// Marks the dispatcher as "busy" before we
// start calling any store handlers.
busy = true;
// The action "type" determines the method
// that we'll call on a the store.
let { type } = payload;
超级会员免费看
订阅专栏 解锁全文
12

被折叠的 条评论
为什么被折叠?



