The first time, write wrong, please correct me.
The event in Backbone.js implements the custom events. A custom event is a key-value pair for an object, key is the event name, and value is a function array. There is a built-in object in the backbone object _events holds all the events
View Code
All events methods are called through EVENTSAPI.
Eventsapi = function (iteratee, events, name, callback, opts) {...}
The OFFAPI,ONCEMAP,TRIGGERAPI is passed in as the first parameter of EVENTSAPI to achieve the off,once,trigger of sexual. Where on and Listento are called by the Internalon method, the Eventsapi,internalon method is to differentiate on and listento by a fifth parameter. The purpose of the Internalon method is to protect the fifth parameter and improve security.
Here are 3 properties of this._events={eventname:[]} and This._listeningto={obj._listenid:{obj:obj, Objid:id, Id:thisid, ListeningTo: Listeningto, count:0}} and This._listeners={obj._listenid:{obj:obj, Objid:id, Id:thisid, Listeningto:listeningto, Count : 0}, these three are map objects. The events class eventually implements operations on these 3 objects.
Note: Events.listento = function (obj, name, callback) {...} This method invokes the This._events,this._listeningto and Obj._listeners three properties at a time
backbone-1.3.3 Source parsing-----------Event