nl_tokens: Internal model event binding handler ( type ( on|once|off ) { event callback context target } )
pl_tokens: function manageEvent ( type , data ) { /*jshint validthis:true */ var _data = { type : type } ; for ( var name in data ) { if ( data . hasOwnProperty ( name ) ) { _data [ name ] = data [ <mask> ] ; } } var watchedEvents = getState ( '__watchedEvents' , this ) ; if ( ! watchedEvents ) { watchedEvents = [ ] ; setState ( { __watchedEvents : watchedEvents } , this ) ; } _data . context = _data . context || this ; watchedEvents . push ( _data ) ; // bind now if we are already mounted (as the mount function won't be called) var target = getTarget ( _data . target , this ) ; if ( this . isMounted ( ) ) { if ( target ) { target [ _data . type ] ( _data . event , _data . callback , _data . context ) ; } } if ( type === 'off' ) { var watchedEvent ; for ( var i = 0 ; i < watchedEvents . length ; i ++ ) { watchedEvent = watchedEvents [ i ] ; if ( watchedEvent . event === data . event && watchedEvent . callback === data . callback && getTarget ( watchedEvent . target , this ) === target ) { watchedEvents . splice ( i , 1 ) ; } } } }