WordPress.org

Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #21170, comment 35


Ignore:
Timestamp:
07/16/12 22:37:53 (2 years ago)
Author:
CaptainN
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #21170, comment 35

    initial v1  
    33It works like this: 
    44 
    5 ''' 
     5{{{ 
    66// setup in core somewhere, or elsewhere 
    77var actions = { 
     
    2424// later when it comes time to cleanup: 
    2525actions.wpAction.myNamespace.remove(); 
    26 ''' 
     26}}} 
    2727 
    2828I didn't add a way to dispatch a Signal only to a namespaced sub-set of listeners, because it didn't seem to make sense to expose that kind of functionality. If a listener was added to a Signal, it seems inappropriate to only send the signal to certain listeners, it adds a second level of subscriber sets, and that can be abused to basically duplicate the dispatcher functionality, where there should probably be a second named action - it may be better to encourage the creation of another distinct hook. 
     
    3030I think event namespaces are mostly useful as a tool for plugin developers to use to be able to clean themselves up, without having to retain a reference to all the listeners they may add all over. 
    3131 
    32 jQuery does support namespaced dispatching, and if there was a strong desire for namespaced dispatching, it could be added easily to SignalsLite.js. I'm not sure how often you'd have plugin or extension developers triggering or dispatching actions and filters (like they frequently do in jQuery), so it may not really be an issue, unless it's wanted for core use. 
     32jQuery does support namespaced dispatching, and if there was a strong desire for namespaced dispatching, it could be added easily to SignalsLite.js. I'm not sure how often you'd have plugin or extension developers triggering or dispatching actions and filters (like they frequently do in jQuery), so it may not really be an issue, unless it's wanted for core use 
     33 
     34Edit: I used the wrong markup format. heh