My favorites | Sign in
Project Logo
             
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*

Copyright (c) 2007. Universal Mind, Inc.
All rights reserved.

This source code is the property of Universal Mind, Inc. ("Universal Mind")
and is licensed, not sold or assigned, to the Universal Mind customer that
obtains this code from Universal Mind.

* This code may not be disclosed to any party without the prior written
consent of Universal Mind.
* This code and may only be used as permitted in the agreement between
Universal Mind and its customer.

This code contains the valuable trade secrets of Universal Mind, the
development of which required the expenditure of considerable time and money.
Unless otherwise expressly set forth in the agreement between Universal
Mind and its customer, this code is provided "as-is" without warranty of
any kind.

Author: Thomas Burleson, Principal Architect
ThomasB@UniversalMind.com
@ignore
*/
package com.universalmind.cairngorm.events
{
import mx.rpc.IResponder;
import mx.rpc.events.*;

/**
* This class is a superset of mx.rpc.Responder that
* allows developers to quickly create a responder with only a resultHandler
* or result, fault, and conflict handlers.
*/
public class Callbacks implements IResponder
{
public static const PRIORITY_BEFORE : int = 0;
public static const PRIORITY_AFTER : int = 1;
public static const PRIORITY_OVERRIDE : int = 2;

/** Result handler function */
public var resultHandler : Function;
/** Fault handler function */
public var faultHandler : Function;
/** Conflict handler function */
public var conflictHandler : Function;
/** Priority of these callbacks over OTHER potential callbacks also registered */
public var priority : int;

/**
* Constructor that allows users to specify result, fault, and conflict handlers.
*
* @resultFunc The function that should be invoked as the resultHandler for a response
* @faultFunc The function that should be invoked as the faultHandler for a response
* @conflicFunc The function that should be invoked as the conflictHandler for a response
*/
public function Callbacks( resultFunc : Function,
faultFunc : Function = null,
conflictFunc: Function = null,
priority : int = PRIORITY_AFTER) {

// This class uses "method closures" to allow dynamic callbacks
// to methods of class instances.
this.resultHandler = resultFunc;
this.faultHandler = faultFunc;
this.conflictHandler = conflictFunc;
}

/** Required method to support the IResponder interface */
public function result(info:Object):void { if (resultHandler != null) resultHandler(info); }
/** Required method to support the IResponder interface */
public function fault(info:Object):void { if (faultHandler != null) faultHandler(info); }
}
}
Show details Hide details

Change log

r15 by Thom...@Universalmind.com on Jan 07, 2008   Diff
Moved remotely
Go to: 
Project members, sign in to write a code review

Older revisions

r11 by Thom...@Universalmind.com on Jan 02, 2008   Diff
Initial source code check-in
All revisions of this file

File info

Size: 2897 bytes, 74 lines

File properties

svn:mime-type
text/plain
svn:eol-style
native
svn:keywords
Id
Hosted by Google Code