Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

7. Applying Business Logic > Command Life Cycle

Command Life Cycle

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.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint