Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有两个 RobotLegs 模型,它们必然是紧密耦合的。在它们之间发送事件的最佳方式是什么?
例如,我想在AppleFarmerModel每次AppleTreeModel调度APPLE_READY事件时通知。
AppleFarmerModel
AppleTreeModel
APPLE_READY
我处理这个问题的方法是让确定苹果是否准备好的命令触发另一个命令,告诉农民检查树。这样,即使农民没有听到任何将来可能有用的信息,您也可以让农民检查树。
根据 robotslegs 规范,模型不监听事件,它们只调度。这是因为模型不应该处理应用程序逻辑。它应该在命令中。
该命令应该决定收集苹果/存储它或例如关闭它。