You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 1-js/09-classes/07-mixins/article.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -165,37 +165,37 @@ let eventMixin = {
165
165
```
166
166
167
167
168
-
- `.on(eventName, handler)` -- assigns function `handler`to run when the event with that name occurs. Technically, there's an `_eventHandlers`property that stores an array of handlers for each event name, and it just adds it to the list.
169
-
- `.off(eventName, handler)` -- removes the function from the handlers list.
170
-
- `.trigger(eventName, ...args)` -- generates the event: all handlers from`_eventHandlers[eventName]`are called, with a list of arguments `...args`.
168
+
- متد `.on(eventName, handler)` -- مشخص میکند که تابع `handler`هنگامی که رویدادی با این نام رخ میدهد اجرا شود. از لحاظ فنی، یک ویژگی `_eventHandlers`وجود دارد که آرایهای از کنترلکنندهها را برای هر رویداد ذخیره میکند و این متد فقط کنترلکننده را به لیست اضافه میکند.
169
+
- متد `.off(eventName, handler)` -- تابع را از لیست کنترلکنندهها حذف میکند.
170
+
- متد `.trigger(eventName, ...args)` -- رویداد را ایجاد میکند: تمام کنترلکنندهها از`_eventHandlers[eventName]`همراه با لیستی از آرگومانها `...args` فراخوانی میشوند.
171
171
172
-
Usage:
172
+
کاربرد:
173
173
174
174
```js run
175
-
//Make a class
175
+
//ایجاد یک کلاس
176
176
classMenu {
177
177
choose(value) {
178
178
this.trigger("select", value);
179
179
}
180
180
}
181
-
//Add the mixin with event-related methods
181
+
//شامل متدهای مربوط به رویداد mixin اضافه کردن
182
182
Object.assign(Menu.prototype, eventMixin);
183
183
184
184
let menu =newMenu();
185
185
186
-
//add a handler, to be called on selection:
186
+
//:فراخوانی شود (select) اضافه کردن یک کنترلکننده، تا هنگام انتخاب
0 commit comments