Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought

Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Author Topic: Lazy proxy?  (Read 7413 times)
Posts: 1

View Profile Email
« on: July 09, 2009, 08:09:27 »

My concern here is to create a proxy that has lazy fetching of remote objects... something like:

// In some Proxy or Mediator


// And in LazyProxy

public function fetchObject(key:String):ValueObject {
if(myValueObjectMap.get(key) == null) {
var result:ValueObject = LazyMagic.get("http://domain.fake/objects?id=" + key);
myValueObjectMap.set(key, result);

return myValueObjectMap.get(key);

What kind of magic does LazyMagic need? :) Or what approach should I have here? I really want to keep the signature of fetchObject to a single parameter to I dont think it's possible. Should I perhaps pass in a function reference as the second parameter, which takes a single parameter (my ValueObject instance)?
Global Moderator
Hero Member
Posts: 2871

View Profile WWW Email
« Reply #1 on: July 09, 2009, 12:25:43 »

The kind of magic you need depends on your definition of 'lazy'. The mediator has asked for the asset. Why don't you make the call right then?

Are you trying to build a list of items before beginning to make calls? The call is async, so making it doesn't block you.

Are you wanting to make sure you don't already have the object? if so, the proxy could just see if it has the object and send a note out with it if it does, or make the call if not.

Also, passing a function reference to a proxy for callback isn't really what you want to do. Invoke a method and expect an immediate return if there is a return type for the method, or if not, expect a notification to come back later, and be interested in that.

Pages: [1]