O'Reilly logo

ActionScript Developer's Guide to Robotlegs by Joel Hooks, Stray

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

Chapter 7. Models and services: How are they different?

You might have heard of MVC and wondered why the S was added for the Robotlegs MVCS architecture. Why separate models from services when they both deal with data most of the time?

Models and services are very similar, but understanding their important differences can help you to use them more effectively. By separating models from services, we provide a clear line in the sand for our classes—boxing off the functionality that they should contain. A service doesn’t store data. A model doesn’t communicate with the outside world to retrieve data. Still—they are closely related. A model is empty without the appropriate service, and a service has no purpose without the models.

Models and Services usually extend Actor

Actor is a very simple base class—just a dependency on the eventDispatcher (a property of Actor) that is shared throughout the application. This allows your models and services to dispatch state and status updates that the whole application can pick up.

It is important to understand that you do not need to extend Actor. Actor is provided for your convenience, to give you the core functionality that is commonly needed by models and services in a Robotlegs application. If your models and services don’t need that core functionality, or you would like them to be reused in a non-Robotlegs code base, you can provide the functionality of Actor manually without extending anything.

They don’t listen, they only talk

Models and services ...

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