开发者

RobotLegs: Sending events between Models?

开发者 https://www.devze.com 2023-02-07 03:33 出处:网络
I\'ve got two two RobotLegs models that are, by necessity, fairly tightly coupled. What\'s the best way to send events between them?

I've got two two RobotLegs models that are, by necessity, fairly tightly coupled. What's the best way to send events between them?

For example, I'd like to notify the AppleFarmerModel each time the AppleTr开发者_StackOverflow中文版eeModel dispatches an APPLE_READY event.


The way I would approach this would be to have the command that determines whether an apple is ready trigger another command that tells the Farmer to check the tree. This way you can get the farmer to check the tree even if they haven't heard anything which may be useful in the future.


By robotlegs specifications Models do not listen to events, they only dispatch. This is because Models should not handle application logic. It should be in the commands.

The command should make the decision to collect the apple/store it or for example dismiss it.

0

精彩评论

暂无评论...
验证码 换一张
取 消