My concern here is to create a proxy that has lazy fetching of remote objects... something like:
// In some Proxy or Mediator
myLazyProxy.fetchObject("Foo");
// 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)?