对通量动作做出反应并存储 class 依赖项

react flux actions and store class dependecies

据我了解 React-Flux 架构,Flux Actions classes 应该通过 AppDispatcher 将他们的事件传播到 Store classes .

但是,我看到一些示例是 Action classes 直接从 Store class 获取数据以执行某些操作...

示例:

import ... /* a few more imports */
import AppDispatcher from 'AppDispatcher.js';
import SomeStore from 'SomeStore.js';


class SomeActions {

    processItemData(){
        var item = SomeStore.getCurrentItem();
        .
        .
        // do something with the item
        .
        .
        // then data dispatched (anyway) to SomeStore or maybe other Store class
        AppDispatcher.dispatch({...}); 
    }
}

如我所见 - 在此处导入 SomeStore.js 破坏了 Flux 架构和数据在应用程序中的流动方式。

问题是,这正常吗?这不是不好的做法吗?

如您所想,这是不正确的,并且打破了 uni-directional 数据流的概念。该操作可以处理组件提供给它的数据,但我不明白为什么它需要或应该需要来自商店的任何数据或知识。

这打破了 inversion of control 的原则,因为操作需要了解商店的自定义实现,而不是简单地分派一个带有数据的事件 - 这就是 flux 正在尝试的架构避免!