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
  • PrintPrint
Share this Page URL
Help

6. The CommandMap in action > Commands should do their thing and then die

Commands should do their thing and then die

When the relevant event fires, the command map automatically creates an instance of each command that is mapped to it, and then runs the execute method. There’s no hard reference kept to the instance of each command created, so it will die and be available for garbage collection as soon as the code triggered by its execute method has finished running.

The lifecycle of a typical Command and its trigger Event
Figure 6-1. The lifecycle of a typical Command and its trigger Event

  

You are currently reading a PREVIEW of this book.

                                                                                                                    

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

  

Start a Free 10-Day Trial


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