Create an $event object type in the Angular namespace for scope events.
Overview
The $rootScope.$on event listener method will pass event as the first parameter. This event object has a documented set of properties and methods.
Problem
This event object is not defined in a namespace and has no definition. It's an inline object defined in the $boardcast function.
This means it can not be defined as a parameter type for event listeners.
For example;
/**
* @param {*} event
* @param {string} key
*/
function onBoardTypeChanged(event,key)
{
//.....
}
$scope.$on("myEvent",onBoardTypeChanged);
Improvement
Create a javascript object in the angular namespace called $event that will be documented using JSDoc the object's properties and methods. This would allow developers to see intellisense auto-complete for event parameters.
The signature of $event would not change. So not problems with backward compatibility.
This would allow developers to define the parameter type for events.
/**
* @param {$event} event
* @param {string} key
*/
function onBoardTypeChanged(event,key)
{
//.....
}
$scope.$on("myEvent",onBoardTypeChanged);
Changes
Could be implemented as a constructor function in rootScope.js. Something like this.
$event: function(name, target) {
this.name = name;
this.targetScope = target,
this.preventDefault = function() {
this.defaultPrevented = true;
}.bind(this);
this.defaultPrevented = false;
},