O'Reilly logo

Professional Cairngorm™ by Jeremy Wischusen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

4.1. What Is It?

The ModelLocator is one of the core singleton classes of the Cairngorm framework. The ModelLocator serves as a central repository for storing data that needs to be accessed in multiple locations. According to the article cited in earlier chapters, "Flex 3: Introducing Cairngorm" (Adobe Customer Training/Partner Enablement Group, Burleson, Shuman, and Boles), the ModelLocator has the following characteristics:

  • It is a global singleton repository for shared or global data.

  • It does not load or persist data to a permanent data store.

  • It does not contain business logic.

  • It supports data binding for auto-notifications of data changes to views.

The ModelLocator class acts as a centralized location for accessing shared data. This data is shared via public properties on the ModelLocator class. Classes that need to access this data retrieve the single instance of the ModelLocator using the static getInstance method and then refer to the public properties.

The ModelLocator differs from other possible implementations of the MVC pattern in that it does not contain any application logic. In some implementations of the MVC pattern the model contains functions for registering the listeners and then notifying them of changes in the data (observer pattern). Cairngorm performs these actions through the Flex data-binding mechanism, and that is how you should have views subscribe to changes in the state of the properties held in the ModelLocator.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required