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: 2-ui/99-ui-misc/03-event-loop/article.md
+36-35Lines changed: 36 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -221,25 +221,25 @@ Bu daha güzel görünüyor:
221
221
222
222
Bir olay işleyicide, bazı eylemleri olay kabarıp tüm seviyelerde işlenene kadar ertelemeye karar verebiliriz. Bunu, kodu sıfır gecikmeli `setTimeout` içine sararak yapabiliriz.
223
223
224
-
<info:dispatch-events> bölümünde bir örnek gördük: `menu-open` özel olayı(custom event) `setTimeout` içinde gönderilir, böylece click" olayı tamamen işlendikten sonra gerçekleşir.
224
+
<bilgi:olayları gönderme(dispatch-events)> bölümünde bir örnek gördük: `menu-open` özel olayı(custom event) `setTimeout` içinde gönderilir, böylece "click" olayı tamamen işlendikten sonra gerçekleşir.
225
225
226
226
```js
227
227
menu.onclick=function() {
228
228
// ...
229
229
230
-
//create a custom event with the clicked menu item data
230
+
//tıklanan menü öğesi verileriyle özel bir olay oluşturun
231
231
let customEvent =newCustomEvent("menu-open", {
232
232
bubbles:true
233
233
});
234
234
235
-
//dispatch the custom event asynchronously
235
+
//özel olayı eşzamansız(asynchronously) olarak gönder
236
236
setTimeout(() =>menu.dispatchEvent(customEvent));
237
237
};
238
238
```
239
239
240
240
## Macrotasks ve Microtasks
241
241
242
-
Bu bölümde açıklanan *macrotasks* ile birlikte, <info:microtasks-sırası> bölümünde bahsedilen *microtasks* vardır.
242
+
Bu bölümde açıklanan *macrotask*'ler ile birlikte, <bilgi:microtasks-sırası> bölümünde bahsedilen *microtask*'ler vardır.
243
243
244
244
Microtask'ler yalnızca kodumuzdan gelir. Genellikle promise'larla oluşturulurlar: `.then/catch/finally` işleyicisinin yürütülmesi bir microtask haline gelir. Microtask'ler, bir başka promise işleme biçimi olduğu için, `wait`'in "örtüsü altında" da kullanılır.
245
245
@@ -258,23 +258,24 @@ Promise.resolve()
258
258
alert("code");
259
259
```
260
260
261
-
What's going to be the order here?
261
+
Buradaki sıra ne olacak?
262
262
263
-
1.`code` shows first, because it's a regular synchronous call.
264
-
2.`promise`shows second, because`.then`passes through the microtask queue, and runs after the current code.
265
-
3.`timeout` shows last, because it's a macrotask.
263
+
1.Sıradan bir eşzamanlı(synchronous) çağrı olduğu için önce `kod` gösterilir.
264
+
2.`promise`ikinci sıradadır, çünkü`.then` microtask kuyruğundan geçer ve geçerli koddan sonra çalışır.
265
+
3.`timeout`'u en son gösterir, çünkü bu bir macrotask'dir.
266
266
267
-
The richer event loop picture looks like this (order is from top to bottom, that is: the script first, then microtasks, rendering and so on):
267
+
Daha zengin olay döngüsü resmi şöyle görünür (sıra yukarıdan aşağıya doğrudur, yani: önce script, ardından microtask'ler, oluşturma(rendering) vb.):
268
268
269
269

270
270
271
-
All microtasks are completed before any other event handling or rendering or any other macrotask takes place.
271
+
Tüm microtask'ler, başka herhangi bir olay işleme(handling) veya oluşturma(rendering) veya başka herhangi bir macrotask gerçekleşmeden önce tamamlanır.
272
272
273
-
That's important, as it guarantees that the application environment is basically the same (no mouse coordinate changes, no new network data, etc) between microtasks.
273
+
Uygulama ortamının microtask'ler arasında temelde aynı olmasını (fare koordinat değişikliği yok, yeni ağ verisi yok, vb.) garanti ettiği için bu önemlidir.
274
274
275
-
If we'd like to execute a function asynchronously (after the current code), but before changes are rendered or new events handled, we can schedule it with `queueMicrotask`.
275
+
Bir fonksiyonu eşzamansız(asynchronously) olarak (geçerli koddan sonra) yürütmek istiyorsak, ancak değişiklikler oluşturulmadan(rendered) veya yeni olaylar işlenmeden(handled) önce, bunu `queueMicrotask` ile zamanlayabiliriz.
276
276
277
277
Here's an example with "counting progress bar", similar to the one shown previously, but `queueMicrotask` is used instead of `setTimeout`. You can see that it renders at the very end. Just like the synchronous code:
278
+
Burada, daha önce gösterilene benzer bir "sayan ilerleme çubuğu" örneği verilmiştir, ancak `setTimeout` yerine `queueMicrotask` kullanılmıştır. En sonunda oluştuğunu(render) görebilirsiniz. Tıpkı senkron kod gibi:
278
279
279
280
```html run
280
281
<divid="progress"></div>
@@ -284,7 +285,7 @@ Here's an example with "counting progress bar", similar to the one shown previou
284
285
285
286
functioncount() {
286
287
287
-
//do a piece of the heavy job (*)
288
+
//ağır işin bir parçasını yap (*)
288
289
do {
289
290
i++;
290
291
progress.innerHTML= i;
@@ -302,39 +303,39 @@ Here's an example with "counting progress bar", similar to the one shown previou
302
303
</script>
303
304
```
304
305
305
-
## Summary
306
+
## Özet
306
307
307
-
A more detailed event loop algorithm (though still simplified compared to the [specification](https://html.spec.whatwg.org/multipage/webappapis.html#event-loop-processing-model)):
308
+
Daha ayrıntılı bir olay döngüsü algoritması (yine de [spesifikasyona](https://html.spec.whatwg.org/multipage/webappapis.html#event-loop-processing-model) kıyasla basitleştirilmiş olsa da):
308
309
309
-
1.Dequeue and run the oldest task from the *macrotask*queue (e.g. "script").
310
-
2.Execute all *microtasks*:
311
-
-While the microtask queue is not empty:
312
-
-Dequeue and run the oldest microtask.
313
-
3.Render changes if any.
314
-
4.If the macrotask queue is empty, wait till a macrotask appears.
315
-
5.Go to step 1.
310
+
1.En eski görevi *macrotask*kuyruğundan ayırın ve çalıştırın (ör. "script").
311
+
2.Tüm *microtask*'leri yürütün:
312
+
-Microtask kuyruğu boş değilken:
313
+
-En eski microtask'i sıraya alın ve çalıştırın.
314
+
3.Varsa oluşturme(render) değişiklikleri.
315
+
4.Macrotask kuyruğu boşsa, bir macrotask görünene kadar bekleyin.
316
+
5.1.Adıma gidin.
316
317
317
-
To schedule a new *macrotask*:
318
-
-Use zero delayed `setTimeout(f)`.
318
+
Yeni bir *macrotask* zamanlamak için:
319
+
-Sıfır gecikmeli `setTimeout(f)` kullanın.
319
320
320
-
That may be used to split a big calculation-heavy task into pieces, for the browser to be able to react to user events and show progress between them.
321
+
Bu, tarayıcının kullanıcı olaylarına tepki verebilmesi ve aralarındaki ilerlemeyi gösterebilmesi için büyük bir hesaplama ağırlıklı görevi parçalara ayırmak için kullanılabilir.
321
322
322
-
Also, used in event handlers to schedule an action after the event is fully handled (bubbling done).
323
+
Ayrıca, olay tamamen işlendikten (köpürme işlemi) sonra bir eylem zamanlamak için olay işleyicilerinde kullanılır.
323
324
324
-
To schedule a new *microtask*
325
-
-Use `queueMicrotask(f)`.
326
-
-Also promise handlers go through the microtask queue.
325
+
Yeni bir *microtask* planlamak için
326
+
-`queueMicrotask(f)` kullanın.
327
+
-Ayrıca promise işleyicileri microtask kuyruğundan geçer.
327
328
328
-
There's no UI or network event handling between microtasks: they run immediately one after another.
329
+
Microtask'ler arasında UI veya ağ olayı işleme yoktur: Bunlar birbiri ardına hemen çalışır.
329
330
330
-
So one may want to `queueMicrotask` to execute a function asynchronously, but within the environment state.
331
+
Bu nedenle, bir fonksiyonu eşzamansız(asynchronously) olarak ancak ortam durumu içinde yürütmek için `queueMicrotask` isteyebilirsiniz.
331
332
332
333
```smart header="Web Workers"
333
-
For long heavy calculations that shouldn't block the event loop, we can use [Web Workers](https://html.spec.whatwg.org/multipage/workers.html).
334
+
Olay döngüsünü engellememesi gereken uzun ağır hesaplamalar için [Web Workers](https://html.spec.whatwg.org/multipage/workers.html)'ı kullanabiliriz.
334
335
335
-
That's a way to run code in another, parallel thread.
336
+
Bu, başka bir paralel iş parçacığında(thread) kod çalıştırmanın bir yoludur.
336
337
337
-
Web Workers can exchange messages with the main process, but they have their own variables, and their own event loop.
338
+
Web Workers ana süreçle mesaj alışverişinde bulunabilirler, ancak kendi değişkenleri ve kendi olay döngüleri vardır.
338
339
339
-
Web Workers do not have access to DOM, so they are useful, mainly, for calculations, to use multiple CPU cores simultaneously.
340
+
Web Worker'larının DOM'a erişimi yoktur, bu nedenle, esas olarak hesaplamalar için, aynı anda birden fazla CPU çekirdeği kullanmak için yararlıdırlar.
0 commit comments