An old-style JavaScript implementation for PureMVC: http://puremvc.org
THIS IS NOT AN OFFICIAL PORT OF PUREMVC, WHICH IS CURRENTLY PENDING COPYRIGHT APPROVAL.
This repository may be removed if not approved officially, since PureMVC is currently planning its own official port.
The PureMVC is a lightweight, MVC framework, designed to help implementing scalable and maintainable applications. It was originally written in ActionScript 3, and now it's been ported to a wide variety of platforms, including C#, Java, PHP, Ruby and JavaScript.
Basically, it relies on well known and proven design patterns, which allows
communication between the different tiers (Model
, View
and Controller
) and
components, and hides the complexity from the developer.
Here's a quick overview:
- Model
A Singleton that caches named references to Proxies.
- Proxies Helps to expose an API for manipulating the Data Model.
- View
A Singleton that caches named references to Mediators.
- Mediators Create, adapt or reuse existing user interface components.
- Controller
A Singleton that maintains named mappings to Commands.
- Commands
Contains business-logic and orchestrate complex or system-wide activities.
May retrieve and interact with
Proxies
, communicate withMediators
or execute otherCommands
. May be aSimpleCommand
(triggered by aNotification
orMacroCommand
), or aMacroCommand
(executes multiplesSimpleCommands
).
- Commands
Contains business-logic and orchestrate complex or system-wide activities.
May retrieve and interact with
- Façade
A Singleton that initializes and caches the Core actors (
Model
,View
andController
), and provides a single place to access all of their public methods.
The Proxies
, Mediators
and Commands
communicate with each other through
Notifications
. Even on platforms with native Event implementations (like
JavaScript or Flash), Notifications
are important to:
- Ensure that the framework works without relying on an specific language;
- Provide a standard way of communication, leaving native Events to listen and
trigger native interactions (like the
click
ormouseover
events in JS).
In PureMVC's context:
Proxies
broadcast, but do not listen forNotifications
Mediators
broadcast AND listen forNotifications
Commands
broadcast AND are triggered byNotifications
The Observer
pattern is responsible for carrying a reference to an object
which wishes to be notified, and the method that should be called when when a
Notification
is broadcast. The View
maps the Notification
names to
Observers
, and notify them when a Notification
is broadcast.
The MVC design and the JavaScript implementation allow the construction of complex interfaces built with several visual components and data retrieved from the server.
Most of the PureMVC implementation is internal to the framework, so you don't need to worry about dealing with all patterns. Regarding PureMVC's framework, you will only be working with:
- Proxies Handling AJAX requests and Data Objects.
- Mediators
Initializing plugins, listing and handling
Notifications
. - SimpleCommands
Initializing a
Widget
, by registeringMediators
andProxies
, and creatingViewComponents
- more on those later. - MacroCommands
Setups a page, initializing
Widgets
by calling theirSimpleCommands
. - Façade
Starts the application, calling the correct
MacroCommand
. Is referenced byProxies
,Mediators
andCommands
to sendNotifications
and register/remove them.
Read more about the PureMVC: