Signals - Listen for Signal from Framework

Bert Deterd's Avatar

Bert Deterd

Jun 22, 2011 @ 12:30 PM

Hello All,

Just getting started with Signals and the SignalCommandMap .
One thing I do not understand yet: how to listen for a Signal in my mediator (onregister). I want to listen for Signals coming from the framework (a Command is the initiator for dispatching the Signal).

Regards,
Bert

  1. 1 Posted by neil on Jun 22, 2011 @ 12:52 PM

    neil's Avatar

    make a typed subclass, map it into your injector as a Singleton
    then inject it into your mediator

  2. 2 Posted by neilmanuell on Jun 22, 2011 @ 01:22 PM

    neilmanuell's Avatar

    Sorry I wasn't clear.

    In the above post I was talking about the Signal.

  3. 3 Posted by ZackPierce on Jun 23, 2011 @ 04:22 AM

    ZackPierce's Avatar

    I like to refer to Signals used in this manner as "independent framework signals." They're not tied to any particular command, and they stand alone like beacons of information.

    To be clear, here's an example of what neil was talking about:


    class StuffIsHappening extends Signal {
        public function StuffIsHappening() {
            super();
        }
    }
    
    // inside the Context, where-ever you do your mapping
    injector.mapSingleton(StuffIsHappening);
    
    class MyMediator extends Mediator {
        [Inject]
        public var stuffIsHappening:StuffIsHappening;
    
        override public function onRegister() {
            stuffIsHappening.add(stuffIsHappeningHandler);
        }
    
        private function stuffIsHappeningHandler():void {
            // Change something about your view component.  Or not.
        }
    }
    
  4. Stray closed this discussion on Jul 21, 2011 @ 03:24 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac