Skip to content

Commit 89171eb

Browse files
committed
Translate a part of article
Line 168 needs more attention.
1 parent 68ed640 commit 89171eb

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

1-js/09-classes/07-mixins/article.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -165,37 +165,37 @@ let eventMixin = {
165165
```
166166
167167
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` فراخوانی می‌شوند.
171171
172-
Usage:
172+
کاربرد:
173173
174174
```js run
175-
// Make a class
175+
// ایجاد یک کلاس
176176
class Menu {
177177
choose(value) {
178178
this.trigger("select", value);
179179
}
180180
}
181-
// Add the mixin with event-related methods
181+
// شامل متدهای مربوط به رویداد mixin اضافه کردن
182182
Object.assign(Menu.prototype, eventMixin);
183183

184184
let menu = new Menu();
185185

186-
// add a handler, to be called on selection:
186+
// :فراخوانی شود (select) اضافه کردن یک کنترل‌کننده، تا هنگام انتخاب
187187
*!*
188188
menu.on("select", value => alert(`Value selected: ${value}`));
189189
*/!*
190190

191-
// triggers the event => the handler above runs and shows:
191+
// :رویداد را راه می‌اندازد => کنترل‌کننده بالا اجرا می‌شود و این را نمایش می‌دهد
192192
// Value selected: 123
193193
menu.choose("123");
194194
```
195195
196-
Now, if we'd like any code to react to a menu selection, we can listen for it with `menu.on(...)`.
196+
حالا اگر ما بخواهیم هر کدی به انتخاب چیزی از فهرست واکنش نشان دهد، می‌توانیم با `menu.on(...)` آن را کنترل کنیم.
197197
198-
And `eventMixin` mixin makes it easy to add such behavior to as many classes as we'd like, without interfering with the inheritance chain.
198+
و `eventMixin` اضافه کردن چنین رفتاری به هر چند کلاسی که بخواهیم را آسان می‌کند، بدون اینکه کاری به زنجیره ارث‌بری داشته باشیم.
199199
200200
## Summary
201201

0 commit comments

Comments
 (0)