InitMonitorProxy

IProxy
Proxy
InitMonitorProxy

com.afw.puremvc.InitMonitor.model

InitMonitorProxy: Sequentially processes a list of Proxies (proxies that implement IInitProxy Interface) This monitor invokes each proxy by calling load() directly.  The Monitor detects via notification when each proxy has completed its processing.

NOTE: (optional) completeNotification should be set before calling start().  This notification is sent when all items have been processed.

TO USE: (using a gallery app as an example...)

  • Register this proxy in StartCommand or whatever: facade.registerProxy(new InitMonitorProxy());
  • Create your Init Proxies by extending InitSimpleProxy or BulkAssetsProxy (make sure they also implement interface IInitProxy)
  • Each proxy must have an associated Event Handler
  • The notification name is returned by completeNotificationName
  • Additional notifications should be added as necessary to your IInitProxy
  • Remember to register the proxy (in StartCommand or something)
  • Create a Command called GalleryInitCommand, the execute() function should look something like this:

var monitor:InitMonitorProxy = (facade.retrieveProxy( InitMonitorProxy.NAME ) as InitMonitorProxy);

monitor.completeNotification = new Notification(ApplicationFacade.GALLERY_INIT_COMPLETE);

monitor.addResources( [ GalleryInitOneProxy.NAME, GalleryInitTwoProxy.NAME ] );

monitor.start();

  • Remember to define ApplicationFacade.GALLERY_INIT_COMPLETE in ApplicationFacade

NOTE: Proxies that extend BulkAssetsProxy should ussually send a _LOADED notification.  Note that for a proxy that never reloads its content when called again, the _LOADED notification is only sent 1X, while the completeNotificationName notification is sent every time.

Summary
InitMonitorProxycom.afw.puremvc.InitMonitor.model
Constants
NAME
Variables
_busy
resources
currIndex
alreadyCompletePNames
noteTOpnameMap
toCompleteCount
completedCount
currCompletedCount
_completeNotification
_progressNotificationName
_startNotificationName
_completeNotificationName
Functions
InitMonitorProxy
stopAlways call stop() before start() to cancel the previous operation and reset the queue
addResourcesCall this function at least 1X before calling start()
startCall this to start the process, !!!remember to call stop() first if this is a new section!!!
startCurrGroup
resourceCompleteGets called by InitResourceCompleteCommand every time a proxy completes Don’t call this function directly
Properties
completeNotificationThe Notification that is sent when all proxies are processed
completeNotificationThis notification is sent after all proxies have issued COMPLETE commands (optional)
progressNotificationName
progressNotificationNameSent each time a proxy is complete
completeNotificationName
completeNotificationName
startNotificationName
startNotificationName

Constants

NAME

public static const NAME: String

Variables

_busy

private var _busy: Boolean

resources

private var resources: Array

currIndex

private var currIndex: int

alreadyCompletePNames

private var alreadyCompletePNames: Object

noteTOpnameMap

private var noteTOpnameMap: Object

toCompleteCount

private var toCompleteCount: int

completedCount

private var completedCount: int

currCompletedCount

private var currCompletedCount: int

_completeNotification

private var _completeNotification: Notification

_progressNotificationName

private var _progressNotificationName: String

_startNotificationName

private var _startNotificationName: String

_completeNotificationName

private var _completeNotificationName: String

Functions

InitMonitorProxy

public function InitMonitorProxy()

stop

public function stop():void

Always call stop() before start() to cancel the previous operation and reset the queue

addResources

public function addResources(resources: Array):void

Call this function at least 1X before calling start()

Parameters

param resources - A array of string names of the proxies to process (ie., MyInitProxy.NAME)

start

public function start():void

Call this to start the process, !!!remember to call stop() first if this is a new section!!!

startCurrGroup

private function startCurrGroup():void

resourceComplete

public function resourceComplete(noteName: String):void

Gets called by InitResourceCompleteCommand every time a proxy completes Don’t call this function directly

Properties

completeNotification

public function get completeNotification():Notification

The Notification that is sent when all proxies are processed

completeNotification

public function set completeNotification(value: Notification):void

This notification is sent after all proxies have issued COMPLETE commands (optional)

progressNotificationName

public function get progressNotificationName():String

progressNotificationName

public function set progressNotificationName(value: String):void

Sent each time a proxy is complete

completeNotificationName

public function get completeNotificationName():String

completeNotificationName

public function set completeNotificationName(value: String):void

startNotificationName

public function get startNotificationName():String

startNotificationName

public function set startNotificationName(value: String):void
public static const NAME: String
private var _busy: Boolean
private var resources: Array
private var currIndex: int
private var alreadyCompletePNames: Object
private var noteTOpnameMap: Object
private var toCompleteCount: int
private var completedCount: int
private var currCompletedCount: int
private var _completeNotification: Notification
private var _progressNotificationName: String
private var _startNotificationName: String
private var _completeNotificationName: String
public function InitMonitorProxy()
public function stop():void
Always call stop() before start() to cancel the previous operation and reset the queue
public function addResources(resources: Array):void
Call this function at least 1X before calling start()
public function start():void
Call this to start the process, !!!remember to call stop() first if this is a new section!!!
private function startCurrGroup():void
public function resourceComplete(noteName: String):void
Gets called by InitResourceCompleteCommand every time a proxy completes Don’t call this function directly
public function get completeNotification():Notification
The Notification that is sent when all proxies are processed
public function get progressNotificationName():String
public function get completeNotificationName():String
public function get startNotificationName():String