topleft topright

Welcome, Guest. Please login or register.
May 18, 2013, 09:08:46 AM
Home Help Search Login Register
News: ATTENTION: Spambots must die! Humans must visit http://contact.futurescale.com to request forum access.

Pages: [1]
Print
Author Topic: Lazy proxy?  (Read 1306 times)
ejot
Newbie
*
Posts: 1


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

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

Code:
// 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? Smiley 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)?
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2790



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

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.

-=Cliff>
Logged
Pages: [1]
Print
Jump to:  



Login with username, password and session length

Powered by SMF 1.1.11 | SMF © 2006-2007, Simple Machines LLC
Copyright © 2006-2008 Futurescale, Inc.