AS3 Signals

I’m loving Robert Penners signals!

Benchmarks are impressive when compared to the native event model, check out Alec McEachrans results which show significant performance gains from Signals.

I’ve recently embraced signals completely and integrated it into a recent project. The benefits for me have been the ability to cleanly interface my event model which is proving handy. I like being able to build component where there is no prerequisite knowledge required to interact with the components event model as the publicly accessed signals make interfacing crystal clear.

On the down side Ive found no way as of yet of knowing what parameters to expect from a dispatched Signal without prior knowledge. Still I’m a Signals convert.

basic signal example:


package 
{
    public class ClassA
    {
        public function ClassA()
        {
            var classB:ClassB = new ClassB();
            classB.mySignal.add( handleSignal );
            classB.test();
        }       
       
        private function handleSignal( value:String ):void
        {
            trace( value );
        }
    }
}

import org.osflash.signals.Signal;

class ClassB
{
    public var mySignal:Signal = new Signal();
   
    public function test():void
    {
        mySignal.dispatch( 'hello world' );
    }
}
Comments (View)
blog comments powered by Disqus

posted : Tuesday, January 18th, 2011