Jump to content

Listening to hierarchy nested events ( e. bubbling )


Recommended Posts


I wonder is there a solution to listen to an event being dispatched from nested object. In my case it looks like this:

SomeScreen is an object extending from PIXI.DisplayObjectContainerSomeComponent which is nested inside SomeScreen, also extends from PIXI.DisplayObjectContainerSomeScreenMediator, having reference to SomeScreen instance

now in SomeComponent i want to dispatch an event, for example:

this.dispatchEvent( { type: 'worldIndexChanged', data: { index: this._currentIndex } } );

and in best scenario I could listen to this event from my mediator by listening to SomeScreen like this:

this.someScreen.addEventListener( 'worldIndexChanged', function(e){ console.log('hey'); } );

and not like this:

this.someScreen.someComponent.addEventListener( 'worldIndexChanged', function(e){ console.log('hey'); } );

I know that this is what event-bubbling is all about, but I wonder is there any way to achive this using PIXI.EventTarget 'class'.


Link to comment
Share on other sites

  • 2 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...