Permalink
Browse files

Removed IDispatcher interface.

  • Loading branch information...
1 parent bb767bf commit c8968424c14445191cb71700842b70ff0b651ac2 @joa committed Nov 22, 2010
View
@@ -5,7 +5,7 @@
<buildFile url="file://$PROJECT_DIR$/build.xml">
<additionalClassPath />
<antReference projectDefault="true" />
- <customJdkName value="" />
+ <customJdkName value="1.6" />
<maximumHeapSize value="128" />
<maximumStackSize value="2" />
<properties />
@@ -15,7 +15,7 @@
<excludeFolder url="file://$MODULE_DIR$/../bin" />
<excludeFolder url="file://$MODULE_DIR$/../report" />
</content>
- <orderEntry type="jdk" jdkName="flexsdk (player 10)" jdkType="Flex SDK Type" />
+ <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="as3-signals libs" level="project" />
</component>
@@ -1,15 +0,0 @@
-package org.osflash.signals
-{
- /**
- *
- */
- public interface IDispatcher
- {
- /**
- * Dispatches an object to listeners.
- * @param valueObjects Any number of parameters to send to listeners. Will be type-checked against valueClasses.
- * @throws ArgumentError <code>ArgumentError</code>: valueObjects are not compatible with valueClasses.
- */
- function dispatch(...valueObjects):void;
- }
-}
@@ -33,6 +33,13 @@ package org.osflash.signals
* @return the listener Function passed as the parameter
*/
function addOnce(listener:Function):Function;
+
+ /**
+ * Dispatches an object to listeners.
+ * @param valueObjects Any number of parameters to send to listeners. Will be type-checked against valueClasses.
+ * @throws ArgumentError <code>ArgumentError</code>: valueObjects are not compatible with valueClasses.
+ */
+ function dispatch(...valueObjects):void;
/**
* Unsubscribes a listener from the signal.
@@ -19,7 +19,7 @@ package org.osflash.signals
* <br/><br/>
* Project home: <a target="_top" href="http://github.com/robertpenner/as3-signals/">http://github.com/robertpenner/as3-signals/</a>
*/
- public class Signal implements ISignal, IDispatcher
+ public class Signal implements ISignal
{
protected var _valueClasses:Array; // of Class
protected var bindings:SignalBindingList;
@@ -26,9 +26,10 @@ package org.osflash.signals.natives
/**
* Dispatches an event to listeners.
* @param event An instance of a class that is or extends flash.events.Event.
+ * @throws ArgumentError <code>ArgumentError</code>: Event object is <code>null</code>.
* @throws ArgumentError <code>ArgumentError</code>: Event object [event] is not an instance of [eventClass].
* @throws ArgumentError <code>ArgumentError</code>: Event object has incorrect type. Expected [eventType] but was [event.type].
*/
- function dispatch(event:Event):Boolean;
+ function dispatchEvent(event:Event):Boolean;
}
}
@@ -119,14 +119,28 @@ package org.osflash.signals.natives
remove(listenerBoxes[i].listener as Function);
}
}
-
+
+ /**
+ * @inheritDoc
+ */
+ public function dispatch(...valueObjects):void
+ {
+ if (null == valueObjects) throw new ArgumentError('Event object expected.');
+
+ if (valueObjects.length != 1) throw new ArgumentError('No more than one Event object expected.');
+
+ dispatchEvent(valueObjects[0] as Event);
+ }
+
/**
* Unlike other signals, NativeSignal does not dispatch null
* because it causes an exception in EventDispatcher.
* @inheritDoc
*/
- public function dispatch(event:Event):Boolean
+ public function dispatchEvent(event:Event):Boolean
{
+ if (null == event) throw new ArgumentError('Event object expected.');
+
if (!(event is _eventClass))
throw new ArgumentError('Event object '+event+' is not an instance of '+_eventClass+'.');
@@ -30,7 +30,6 @@ package org.osflash.signals
public var _DeluxeSignalDispatchExtraArgsTest:DeluxeSignalDispatchExtraArgsTest;
public var _DeluxeSignalDispatchNoArgsTest:DeluxeSignalDispatchNoArgsTest;
public var _DeluxeSignalDispatchNonEventTest:DeluxeSignalDispatchNonEventTest;
- public var _DeluxeSignalSplitInterfacesTest:DeluxeSignalSplitInterfacesTest;
public var _DeluxeSignalWithBubblingEventTest:DeluxeSignalWithBubblingEventTest;
public var _DeluxeSignalWithCustomEventTest:DeluxeSignalWithCustomEventTest;
public var _DeluxeSignalWithGenericEventTest:DeluxeSignalWithGenericEventTest;
@@ -41,7 +40,6 @@ package org.osflash.signals
public var _SignalDispatchExtraArgsTest:SignalDispatchArgsTest;
public var _SignalDispatchNoArgsTest:SignalDispatchNoArgsTest;
public var _SignalDispatchNonEventTest:SignalDispatchNonEventTest;
- public var _SignalSplitInterfacesTest:SignalSplitInterfacesTest;
public var _SignalTest:SignalTest;
public var _SignalWithCustomEventTest:SignalWithCustomEventTest;
}
@@ -1,41 +0,0 @@
-package org.osflash.signals
-{
- import asunit.asserts.*;
- import asunit.framework.IAsync;
-
- public class DeluxeSignalSplitInterfacesTest
- {
- [Inject]
- public var async:IAsync;
-
- // Notice the use of the smaller IPrioritySignal interface, rather than ISignalOwner.
- // This makes dispatch() inaccessible unless the Signal is typed to IDispatcher.
- public var completed:IPrioritySignal;
-
- [Before]
- public function setUp():void
- {
- completed = new DeluxeSignal(this);
- }
-
- [After]
- public function tearDown():void
- {
- DeluxeSignal(completed).removeAll();
- completed = null;
- }
- //////
- [Test]
- public function cast_to_IDispatcher_and_dispatch_should_work():void
- {
- completed.addOnce( async.add(onCompleted, 10) );
- IDispatcher(completed).dispatch();
- }
-
- private function onCompleted():void
- {
- assertEquals(0, arguments.length);
- }
-
- }
-}
@@ -1,47 +0,0 @@
-package org.osflash.signals
-{
- import asunit.asserts.*;
- import asunit.framework.IAsync;
-
- public class SignalSplitInterfacesTest
- {
- [Inject]
- public var async:IAsync;
-
- // Notice the use of the ISignal interface, rather than Signal.
- // This makes dispatch() inaccessible unless the ISignal is cast to IDispatcher or Signal.
- public var completed:ISignal;
-
- [Before]
- public function setUp():void
- {
- completed = new Signal();
- }
-
- [After]
- public function tearDown():void
- {
- Signal(completed).removeAll();
- completed = null;
- }
-
- [Test]
- public function cast_ISignal_to_IDispatcher_and_dispatch():void
- {
- completed.addOnce( async.add(onCompleted, 10) );
- IDispatcher(completed).dispatch();
- }
-
- private function onCompleted():void
- {
- assertEquals(0, arguments.length);
- }
-
- [Test]
- public function cast_ISignal_to_Signal_and_dispatch():void
- {
- completed.addOnce( async.add(onCompleted, 10) );
- Signal(completed).dispatch();
- }
- }
-}

0 comments on commit c896842

Please sign in to comment.