Domanda

Ho due due modelli RobotLegs che sono, per necessità, piuttosto strettamente accoppiati. Qual è il modo migliore per inviare gli eventi tra loro?

Per esempio, vorrei informare il AppleFarmerModel ogni volta che il AppleTreeModel invia un evento APPLE_READY.

È stato utile?

Soluzione

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.

Altri suggerimenti

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top