0
votes

I am working on a flex application which makes calls to an .NET webservice. I am trying to follow the MVC design pattern. I have created a model, which stores all information received from the webservice. The webservice itself is created by actionscript in the controller. The view in my case, consists of various user-defined components (multiple .mxml files).

The Model is a singleton class, and each of the views accesses a getInstance of the model. The question is how do i access the webservice (i.e. controller) from each of these components? Does the controller also need to be a singleton class just like the model? and let each component get an instance of the controller in order to access the webservice?

1

1 Answers

1
votes

In Cairngorm they use a ServiceLocator singleton, in an IoC framework (eg Parsley) you can create an object which can get injected into your view.

Taking a step back though, your view shouldn't know about the web service, only about reading the model. the view should fire an event asking for data, this can be caught and acted upon (a Command in Cairngom), wherein the Model can be updated. Since your view is binding to the model, when the data gets updated, the view gets updated.