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/11-async/05-promise-api/article.md
+27-23Lines changed: 27 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -88,11 +88,12 @@ Promise.all([
88
88
]).then(alert); // 1,2,3 sözler hazır olduğunda: her söz bir dizi üyesine katkıda bulunur
89
89
```
90
90
91
-
Please note that the relative order is the same. Even though the first promise takes the longest time to resolve, it is still first in the array of results.
91
+
Lütfen göreli siparişin aynı olduğunu unutmayın. İlk sözün sözülmesi uzun sürse bile sonuçta ilk sırada yer almaktadır.
92
92
93
-
A common trick is to map an array of job data into an array of promises, and then wrap that into `Promise.all`.
93
+
Yayın bir hile, bir dizi iş verisini bir dizi sözle eşleştirmek ve ardından bunu `Promise.all` içine kaydırmaktır.
94
+
95
+
Örneğin, eğer bir dizi URL'miz varsa hepsini şöyle getirebiliriz:
94
96
95
-
For instance, if we have an array of URLs, we can fetch them all like this:
A bigger example with fetching user information for an array of github users by their names (or we could fetch an array of goods by their ids, the logic is same):
115
+
Bir dizi github kullanıcısı için kullanıcı bilgilerini adlarına göre almakla ilgili daha büyük bir örnek (veya bir mal dizisini kimlikleriyle alabiliriz. Mantık aynıdır):
116
+
115
117
116
118
```js run
117
119
let names = ['iliakan', 'remy', 'jeresig'];
@@ -120,22 +122,22 @@ let requests = names.map(name => fetch(`https://api.github.com/users/${name}`));
120
122
121
123
Promise.all(requests)
122
124
.then(responses=> {
123
-
//all responses are ready, we can show HTTP status codes
125
+
//Tüm cevaplar hazır. HTTP durum kodlarını gösterebiliriz
124
126
for(let response of responses) {
125
-
alert(`${response.url}: ${response.status}`); //shows 200 for every url
127
+
alert(`${response.url}: ${response.status}`); //Her URL için 200 gösterir
126
128
}
127
129
128
130
return responses;
129
131
})
130
-
//map array of responses into array of response.json() to read their content
132
+
//Yanıt dizisini, içeriğini okumak için response.json() dizisine eşleyin
**If any of the promises is rejected,`Promise.all`immediately rejects with that error.**
138
+
**Eğer sözlerden herhangi biri ret edildiyse `Promise.all`bu hatayı hemen ret eder**
137
139
138
-
For instance:
140
+
Örneğin:
139
141
140
142
```js run
141
143
Promise.all([
@@ -147,47 +149,49 @@ Promise.all([
147
149
]).catch(alert); // Error: Whoops!
148
150
```
149
151
150
-
Here the second promise rejects in two seconds. That leads to immediate rejection of `Promise.all`, so `.catch` executes: the rejection error becomes the outcome of the whole `Promise.all`.
152
+
İşte ikinci söz iki saniye içinde reddediyor. Bu `Promise.all`un hemen reddedilmesine yol açar, bu yüzden `.catch` çalıştırır: reddedilme hatası tüm `Promise.all`un sonucudur.
153
+
151
154
152
155
```warn header="In case of an error, other promises are ignored"
153
-
If one promise rejects, `Promise.all` immediately rejects, completely forgetting about the other ones in the list. Their results are ignored.
156
+
Eğer bir söz reddederse, `Promise.all` derhal reddeder. Listedeki diğerlerini tamamen unutur. Onların sonuçları göz ardı edilir.
154
157
155
-
For example, if there are multiple `fetch` calls, like in the example above, and one fails, other ones will still continue to execute, but `Promise.all` don't watch them any more. They will probably settle, but the result will be ignored.
158
+
Örneğin, yukarıdaki örnekte olduğu gibi birden fazla `fetch` çağrısı varsa ve biri başarısız olursa diğeri hala yürütülmeye devam eder. Ancak `Promise.all` artık onları izlememektedir. Muhtemelen yerleşecekler ancak sonuç göz ardı edilecektir.
156
159
157
-
`Promise.all` does nothing to cancel them, as there's no concept of "cancellation" in promises. In [another chapter](fetch-abort) we'll cover `AbortController` that aims to help with that, but it's not a part of the Promise API.
160
+
`Promise.all` sözlerinde "iptal" kavramı olmadığı için onları iptal edecek hiçbir şey yapmaz. [Başka bir bölümde](fetch-abort) bu konuda yardımcı olmayı amaçlayan `AbortController`ı ele alacağız. Ancak bu Promise API'sinin bir parçası değil.
158
161
```
159
162
160
163
````smart header="`Promise.all(...)` allows non-promise items in `iterable`"
161
-
Normally, `Promise.all(...)` accepts an iterable (in most cases an array) of promises. But if any of those objects is not a promise, it's wrapped in `Promise.resolve`.
164
+
Normalde, `Promise.all(...)` sözlerin yenilenebilir (çoğu durumda bir dizi) kabul eder. Ancak bu nesnelerden herhangi biri bir söz değilse `Promise.respove` içine sarılır.
165
+
```
162
166
163
-
For instance, here the results are `[1, 2, 3]`:
167
+
Örneğin burada `[1, 2, 3]` döner:
164
168
165
169
```js run
166
170
Promise.all([
167
171
new Promise((resolve, reject) => {
168
172
setTimeout(() => resolve(1), 1000)
169
173
}),
170
-
2, //treated as Promise.resolve(2)
171
-
3//treated as Promise.resolve(3)
174
+
2, // Promise.resolve(2) olarak kabul edildi.
175
+
3 // Promise.resolve(3) olarak kabul edildi.
172
176
]).then(alert); // 1, 2, 3
173
177
```
174
178
175
-
So we are able to pass non-promise values to `Promise.all` where convenient.
179
+
Bu yüzden uygun olmayan durumlarda `Promise.all`a söz etmeyen değerleri aktarabiliriz.
176
180
177
181
````
178
182
179
183
## Promise.allSettled
180
184
181
185
[recent browser="new"]
182
186
183
-
`Promise.all` rejects as a whole if any promise rejects. That's good in cases, when we need *all* results to go on:
187
+
Herhangi bir söz reddederse `Promise.all` bir bütün olarak eder. Devam etmek için *all* sonuçlarına ihtiyacımız olduğunda bu iyidir:
184
188
185
189
```js
186
190
Promise.all([
187
191
fetch('/template.html'),
188
192
fetch('/style.css'),
189
193
fetch('/data.json')
190
-
]).then(render); // render method needs them all
194
+
]).then(render); // render yöntemi hepsine ihtiyaç duyuyor
191
195
```
192
196
193
197
`Promise.allSettled` waits for all promises to settle: even if one rejects, it waits for the others. The resulting array has:
0 commit comments