Skip to content

Conversation

@nest-aka-swan
Copy link

No description provided.

@honest-hrundel
Copy link

🍏 Пройдено тестов 13 из 13

on: function (event, context, handler) {
console.info(event, context, handler);
var times = arguments[3] || Infinity;
var frequency = arguments[4] || 1;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Для отрицательных чисел должно работать просто как метод on

this.events[evt] = this.events[evt].filter(function (listener) {
return listener.context !== context;
});
}.bind(this));
Copy link

@ninjagrizzly ninjagrizzly Nov 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Функция forEach принимает вторым аргументом контекст, то есть можно писать так
forEach(function (args) {...}, this)

if (listeners) {
listeners
.filter(function (listener) {
return listener.timesCalled !== listener.times;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут проверяешь на !== и еще внутри функции callHandler проверяется условие this.timesCalled < this.times. Можешь пояснить зачем так?

* @param {String} event
* @returns {Object}
*/
emit: function (event) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно удалять события several из общего списка после вызова их n раз

@ninjagrizzly
Copy link

🍅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants