-
Notifications
You must be signed in to change notification settings - Fork 59
Лебедев Никита #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Лебедев Никита #54
Conversation
|
🍏 Пройдено тестов 13 из 13 |
| on: function (event, context, handler) { | ||
| console.info(event, context, handler); | ||
| var times = arguments[3] || Infinity; | ||
| var frequency = arguments[4] || 1; |
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Можно удалять события several из общего списка после вызова их n раз
|
🍅 |
No description provided.