Hi,

To address your case of wanting to execute code before and after the  
fault and result methods of IResponder, would it be sufficient to  
create an implementation of IResponder that takes another IResponder  
and wraps that object's fault and response methods.  Something like:


class ResponderWrapper implements IResponder {

        private var _wrappedResponder;

        public ResponderWrapper(wrapped:IResponder) {
                _wrappedResponder = wrapped;
        }

        public function fault() {
                // your pre-execution code here
                _wrappedResponder.fault()
                // your post-execution code here
        }

        // and similarly for result.
}

You then use ResponderWrapper in place of the 'wrapped' IResponder.

Further flexibility could be achieved by passing in additional  
parameters that are functions defining the pre and post execution  
operations when constructing this object.   I have found this kind of  
'decorator' approach quite useful in the past.

Regarding the use of 'apply' - I think you are correct that you  
cannot use 'apply' on a method, for methods 'this' always is the  
owning object, even if you are referring to a method via a variable  
of type function.

HTH
Stephen

Reply via email to