☑ What is the order of event callbacks using 'this.app.fire'

With this picture , I want to know how about the order of the function execute when the game:reset fire ?

The order of execution for the event callbacks depends on the order in which this.app.on was called. So you can’t know that just by looking at this picture.

One thing you can do is examine this.app._callbacks in the browser console. This object contains all the event handlers for this.app (each event emitter contains a _callbacks object). There you can see what handlers exist for each event name and check out their order in the array.

Dear vaios

Thank you for your answer.

I know what you mean and it’s a good way for me.

I want to ask you another question.

If I have 5 javascript files,they are 1.js 2.js 3.js and so on.

In the 1.js , I write down

this.app.on('game:reset',this.reset,this)

In the 2.js , I write down this , too

this.app.on('game:reset',this.reset,this)

3.js

this.app.on('game:reset',this.reset,this)

4.js

this.app.on('game:reset',this.reset,this)

And then,in the 5.js,I write down

this.app.fire('game:reset')

When the ‘game:reset’ fire,I want to know the order of callback function between 1.js to 4.js and the reason of the order without the console.

Could you tell me?

When you call this.app.on what that basically does is add your callback to an array. So depending on the order that each script is running, this.app.on will be called at some point for each script and that will add the callback of each script to the same array. The names of your scripts don’t matter when it comes to execution order ( more about this here http://developer.playcanvas.com/en/user-manual/scripting/loading-order/ ).

Aha , thank you so much vaios.

I get.