Class com.bumpslide.services.ServiceProxy

????
   +--Dispatcher
      +--com.bumpslide.services.ServiceProxy

Description

Single point of access for all services in an application

This class is meant to be extended once for each application. Services can be added automagically using the addServiceMethod function, but it is better to create actual stub methods in you service proxy implementation so that you can make use of proper code-hinting while developing the client code in view classes.

The service proxy enqueues all service requests and performs some smart checking to determine whether or not a service really needs to be called. Stale service calls (calls to services already in the queue, but with different params) can be automatically removed to avoid unnecessary server calls.

Example Usage:

  	var service = ServiceProxy.getInstance();
   
 		// services normally added in subclass iniServices method...
 		service.addServiceMethod( "loadMyData", MyDataService );
 
   	// in client we then listen nad load
   	service.addEventListener("onServiceResult_loadMyData", this);
   	dataLoader.loadMyData(2027477); 
 
   	function onServiceResult_loadMyData( myData ) {
			traceObj( myData );
		}
	

Field Index

debug

Method Index

addServiceMethod(), getCurrentRequest(), getInstance(), initServices(), reset()

Field Detail

debug

public debug:Boolean

Method Detail

getInstance

static public function getInstance()

static method, used to make 1 instance (singleton) this must be replicated in the subclass implementation

getCurrentRequest

public function getCurrentRequest():ServiceRequest

Returns service request currently being processed

Return

reset

public function reset()

initServices

public function initServices()

Subclasses should init services here This is where ServiceProxy subclass implementations should call addServiceMethod for each service class

addServiceMethod

public function addServiceMethod(serviceClass:Function, methodName:String)

Dynamically creates a method in the proxy instance using method name The dynamically created method will run/request the service defined in the serviceClass

Parameters

serviceClass
methodName