NUI Event Listeners - Multiple vs Singular

Hi, so I’ve been learning and developing NUI with Vue.js and C# and so far its going well, but I have been debating whether to use a single event listener for all my events or to separate them (i.e. one for reading vehicle status one for player status).
I think a singular event listener is more efficient? but having to pass the data to the other components may be counter-intuitive.
TL:DR What is the best practice? Or does it not really matter?
Thanks in advance!! :smiley:

tbh do it the way you find easiest and you can always optimize it with the more you practice

2 Likes

I would argue that neither is more “efficient” than the other, and it all comes down to personal preference and how you want your script to work/be laid out.

Do what you feel is right.

2 Likes

Another thing to consider is much larger resources with NUIs (think entire frameworks) may have lots of JS, so it can be useful to have one JS file per “module” (e.g. Properties related NUI, Phone related NUI, etc.), with each JS file listening for one sub-type of event (e.g. Properties events, Phone events, etc.), then you’d have different events within those sub-types. Food for thought.

2 Likes

Thanks for the replies. I think i will go for multiple for now as it makes more sense to me and I will be fairly large NUI mod when I’m done.

1 Like