2009
09.14

signals

Robert Penner, the god father of the tweening equations is jamming the air waves with his new signals library. The new library is aimed at providing a better event dispatcher/handler system for AS3. The library was inspired by C# events and signals/slots in Qt.

Here’s some basic info about the library.

The Concept

  • A Signal is essentially a mini-dispatcher specific to one event, with its own array of listeners.
  • A Signal gives an event a concrete membership in a class.
  • Listeners subscribe to real objects, not to string-based channels.
  • Event string constants are no longer needed.

Features

  • Remove all event listeners:
  • Retrieve the number of listeners
  • Listeners can be added for a one-time call and removed automatically on dispatch:
  • Any object type can be dispatched to listeners. But using IEvent will enable full functionality.
  • A Signal can be initialized with an event class that will validate event objects on dispatch (optional):
  • If the Signal’s event class is specified, each listener is checked on add() to ensure it declares at least one argument.
  • Signals can be placed in interfaces to indicate the events dispatched by a class.
  • Events can bubble recursively through .parent independent of the display list (experimental).
  • Code was developed test-first.

I know that people are creatures of habit, so it will be interesting to see if this takes off as a new standard. Even still Penner has been very open to discussion about the library on his blog and has already made adjustments to signals from suggestions by the community. I’m very excited to see what comes from all this good hard work.

Any day that smart people work hard to make good reusable code for the community is a good day! So here’s to you Penner/Community – Cheers!

http://code.google.com/p/as3-signals/

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • MySpace
  • StumbleUpon
  • Technorati
  • Blogplay
  • email
  • RSS
  • Twitter
  • Yahoo! Bookmarks

1 comment so far

Add Your Comment
  1. Thanks for the mention, Josh. I’ve actually moved the project from Google Code to Github:

    http://github.com/robertpenner/as3-signals