/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

  1. package 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. /** The current number of listeners for the signal. */
  14. function get numListeners():uint;
  15. /**
  16. * Subscribes a one-time listener for this signal.
  17. * The signal will remove the listener automatically the first time it is called,
  18. * after the dispatch to all listeners is complete.
  19. * @param listener A function with arguments
  20. * that matches the value classes dispatched by the signal.
  21. * If value classes are not specified (e.g. via Signal constructor), dispatch() can be called without arguments.
  22. * @return a ISlot, which contains the Function passed as the parameter
  23. */
  24. function addOnce(listener:Function):ISlot;
  25. /**
  26. * Dispatches an object to listeners.
  27. * @param valueObjects Any number of parameters to send to listeners. Will be type-checked against valueClasses.
  28. * @throws ArgumentError <code>ArgumentError</code>: valueObjects are not compatible with valueClasses.
  29. */
  30. function dispatch(...valueObjects):void;
  31. /**
  32. * Unsubscribes a listener from the signal.
  33. * @param listener
  34. * @return a ISlot, which contains the Function passed as the parameter
  35. */
  36. function remove(listener:Function):ISlot;
  37. /**
  38. * Unsubscribes all listeners from the signal.
  39. */
  40. function removeAll():void
  41. }
  42. }