Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Commands are typically registered
in your ApplicationFacade’s initializeController() method, where you
register one or more Notification names
to a given Command class.
Unlike the Proxy and Mediator, there are no onRegister() and onRemove() methods for a Command; it is a short-lived actor. A Command is instantiated when any of the Notifications it was registered to are sent by
any other actor. Once the Command has
done its work, the framework does not keep any reference to it, so it
should be garbage-collected as long as no other actor has a reference.
Thus, you should avoid setting listeners on anything in a Command. In addition, Commands should be stateless, but if you need to
track, for instance, how many times a Command has run, you might hold that in a class
variable rather than an instance variable.