diff --git a/src/event/Eventable.js b/src/event/Eventable.js index e002ec0..d2d42cc 100644 --- a/src/event/Eventable.js +++ b/src/event/Eventable.js @@ -106,27 +106,6 @@ module.exports = Interface( 'Eventable', addListener: [ 'ev', 'listener' ], - /** - * Determine whether LISTENER is listening for messages emitted by event - * EV - * - * If event EV is not valid, either `false` shall be returned or - * an error shall be thrown, since LISTENER cannot possibly hook an - * invalid event. - * - * This method is not intended as an introspective/reflection - * mechanism---it allows a consumer of an Eventable object to determine - * whether LISTENER has already been hooked before blindly - * hooking/unhooking it. - * - * @param {string} ev event id - * @param {Function} listener listener to query for - * - * @return {boolean} whether LISTENER hooks event EV - */ - hooksEvent: [ 'ev', 'listener' ], - - /** * Unhook LISTENER from event EV, preventing further messages from being * received diff --git a/src/event/Evented.js b/src/event/Evented.js index 9ff96b5..532c472 100644 --- a/src/event/Evented.js +++ b/src/event/Evented.js @@ -296,7 +296,7 @@ module.exports = Trait( 'Evented' ) * * @return {boolean} whether LISTENER hooks event EV */ - hooksEvent( ev, listener ) + 'protected hooksEvent'( ev, listener ) { let levdata = listener[ this._evid ]; return !!( levdata && ( levdata[ ev ] !== undefined ) ); diff --git a/test/event/EventedTest.js b/test/event/EventedTest.js index 34be455..622b232 100644 --- a/test/event/EventedTest.js +++ b/test/event/EventedTest.js @@ -617,55 +617,6 @@ describe( 'event.Evented', () => } ); - describe( '#hooksEvent', () => - { - var ev = 'foo', - f; - - beforeEach( () => - { - // ensure fresh listener - f = () => {}; - } ); - - - it( 'recognizes listener for a hooked event', () => - { - stub.evDefineEvents( [ ev ] ) - .on( ev, f ); - - expect( stub.hooksEvent( ev, f ) ).to.be.true; - } ); - - - it( 'does not recognize listener for non-hooked event', () => - { - expect( stub.hooksEvent( ev, f ) ).to.be.false; - } ); - - - /** - * Technically this test is sufficient to make the previous two - * redundant, but they are retained for clairty in debugging. - */ - it( 'does not recognize listeners of other events', () => - { - var ev2 = 'bar', - f2 = () => {}; - - stub.evDefineEvents( [ ev, ev2 ] ) - .on( ev, f ) - .on( ev2, f2 ); - - expect( stub.hooksEvent( ev, f ) ).to.be.true; - expect( stub.hooksEvent( ev2, f ) ).to.be.false; - - expect( stub.hooksEvent( ev, f2 ) ).to.be.false; - expect( stub.hooksEvent( ev2, f2 ) ).to.be.true; - } ); - } ); - - describe( 'listener metadata', () => { /**