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
+15-15Lines changed: 15 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,9 +17,9 @@ Buradaki gibi:
17
17
let promise =newPromise(resolve=>resolve(value));
18
18
```
19
19
20
-
The method is used when we already have a value, but would like to have it "wrapped" into a promise.
20
+
Yöntem zaten bir değere sahipken kullanılır. Ancal bir söz içine "sarılmış" olmasını ister.
21
21
22
-
For instance, the `loadCached`function below fetches the `url` and remembers the result, so that future calls on the same URL return it immediately:
22
+
Örneğin, `loadCached`fonksiyonu aşağıda `url`yi alır ve sonucu hatırlar. Böylece aynı URL'deki gelecekteki çağrılar hemen döndürülür.
23
23
24
24
```js
25
25
functionloadCached(url) {
@@ -40,52 +40,52 @@ function loadCached(url) {
40
40
}
41
41
```
42
42
43
-
We can use `loadCached(url).then(…)`, because the function is guaranteed to return a promise. That's the purpose `Promise.resolve`serves in the line `(*)`: it makes sure the interface is unified. We can always use `.then` after `loadCached`.
43
+
`loadCached(url).then(…)` kullanabiliriz. Çünkü fonksiyonun bir söz döndürmesi garantilidir. Amaç `Promise.resolve``(*)` doğrultusunda hizmet eder: Arayüzünün birleşik olduğundan emin olun. `.then`den sonra her zaman `loadCached` kullanabiliriz.
44
44
45
45
## Promise.reject
46
46
47
-
The syntax:
47
+
Söz dizimi:
48
48
49
49
```js
50
50
let promise =Promise.reject(error);
51
51
```
52
52
53
-
Create a rejected promise with the `error`.
53
+
`error` ile reddedilen bir söz oluşturun.
54
54
55
-
Same as:
55
+
Yukarıdaki ile aynı:
56
56
57
57
```js
58
58
let promise =newPromise((resolve, reject) =>reject(error));
59
59
```
60
60
61
-
We cover it here for completeness, rarely used in real code.
61
+
Gerçek kodda nadiren kullanılan, bütünlük için buradayız.
62
62
63
63
## Promise.all
64
64
65
-
Let's say we want to run many promises to execute in parallel, and wait till all of them are ready.
65
+
Paralel olarak yürütülmek için birçok söz vermek isteriz ve hepsinin hazır olmasını bekleriz.
66
66
67
-
For instance, download several URLs in parallel and process the content when all are done.
67
+
Örneğin, paralel olarak birkaç URL'yi indirin ve hepsi bittiğinde içeriği işleyin.
68
68
69
-
That's what`Promise.all` is for.
69
+
Bunun için`Promise.all`.
70
70
71
-
The syntax is:
71
+
Söz dizimi:
72
72
73
73
```js
74
74
let promise =Promise.all([...promises...]);
75
75
```
76
76
77
-
It takes an array of promises (technically can be any iterable, but usually an array) and returns a new promise.
77
+
Yeni bir söz alır ve bir dizi söz alır (technically can be any iterable, but usually an array.)
78
78
79
-
The new promise resolves when all listed promises are settled and has an array of their results.
79
+
Yeni söz, listelenen tüm sözlerin yerine getirildiği ve sonuçların bir dizisine sahip olduğunda karar verir.
80
80
81
-
For instance, the`Promise.all`below settles after 3 seconds, and then its result is an array `[1, 2, 3]`:
81
+
Örneğin, aşağıdaki`Promise.all`3 saniye sonra yerleşir ve sonucu `[1, 2, 3]` dizisidir:
]).then(alert); // 1,2,3 when promises are ready: each promise contributes an array member
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
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.
0 commit comments