Github source code
The following is a snippet of the baseline installation method:
set: function(key, val, options) {
var attr, attrs, unset, changes, silent, changing, prev, current;
...
options || (options = {});
...
if (!silent) {
if (changes.length) this._pending = options;
for (var i = 0, length = changes.length; i < length; i++) {
this.trigger('change:' + changes[i], this, current[changes[i]], options);
}
}
if (changing) return this;
if (!silent) {
while (this._pending) {
options = this._pending;
this._pending = false;
this.trigger('change', this, options);
}
}
this._pending = false;
this._changing = false;
return this;
}
Although the comment mentioned a loop whilethat Iβm interested in, I donβt see how this loop works, since the local variable changingwill always be truein one round set.
Can someone explain to me why there is time, and when will it take effect?
Thanks in advance!
source
share