PageRenderTime 13ms CodeModel.GetById 1ms app.highlight 6ms RepoModel.GetById 2ms app.codeStats 0ms

/src/org/osflash/signals/IOnceSignal.as

http://github.com/robertpenner/as3-signals
ActionScript | 47 lines | 13 code | 5 blank | 29 comment | 0 complexity | 9ff36ccb306598efa60158715f71ab1c MD5 | raw file
 1package org.osflash.signals
 2{
 3	/**
 4	 *
 5	 */
 6	public interface IOnceSignal
 7	{
 8		/**
 9		 * An optional array of classes defining the types of parameters sent to listeners.
10		 */
11		function get valueClasses():Array;
12		function set valueClasses(value:Array):void;
13		
14		/** The current number of listeners for the signal. */
15		function get numListeners():uint;
16		
17		/**
18		 * Subscribes a one-time listener for this signal.
19		 * The signal will remove the listener automatically the first time it is called,
20		 * after the dispatch to all listeners is complete.
21		 * @param	listener A function with arguments
22		 * that matches the value classes dispatched by the signal.
23		 * If value classes are not specified (e.g. via Signal constructor), dispatch() can be called without arguments.
24		 * @return a ISlot, which contains the Function passed as the parameter
25		 */
26		function addOnce(listener:Function):ISlot;
27
28		/**
29		 * Dispatches an object to listeners.
30		 * @param	valueObjects	Any number of parameters to send to listeners. Will be type-checked against valueClasses.
31		 * @throws	ArgumentError	<code>ArgumentError</code>:	valueObjects are not compatible with valueClasses.
32		 */
33		function dispatch(...valueObjects):void;
34		
35		/**
36		 * Unsubscribes a listener from the signal.
37		 * @param	listener
38		 * @return a ISlot, which contains the Function passed as the parameter
39		 */
40		function remove(listener:Function):ISlot;
41
42		/**
43		 * Unsubscribes all listeners from the signal.
44		 */
45		function removeAll():void
46	}
47}