I am trying to set up custom events. I understand how to register and fire custom events. However, it seems that it is not possible to register truly custom events. Everything needs to be traced back to the DOM event, such as click, load, blur, etc. Or I'm wrong?
For example, suppose I have an array. I want to register an event that fires when the length of the array changes. As far as I understand, I would have to register an event, and then create a setInterval timer that checks the current length of the array for the previously saved length. If the length has changed, then I would need to fire my custom event from inside setInterval.
Is there a way to register an event for my array and will it fire automatically when the length changes?
source
share