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
예시의 프라미스는 하나인데 여기에 등록된 핸들러는 여러 개 입니다. 이 핸들러들은 `result`를 순차적으로 전달하지 않고 독립적으로 처리합니다.
89
-
=======
90
-
What we did here is just adding several handlers to one promise. They don't pass the result to each other; instead they process it independently.
91
-
>>>>>>> upstream/master
76
+
예시의 프라미스는 하나인데 여기에 등록된 핸들러는 여러 개입니다. 이 핸들러들은 `result`를 순차적으로 전달하지 않고 독립적으로 처리합니다.
92
77
93
78
그림으로 표현하면 다음과 같습니다. 프라미스 체이닝을 묘사한 위 그림과 비교해 보세요.
94
79
@@ -136,12 +121,8 @@ new Promise(function(resolve, reject) {
136
121
});
137
122
```
138
123
139
-
<<<<<<< HEAD
140
124
예시에서 첫 번째 `.then`은 `1`을 출력하고 `new Promise(…)`를 반환(`(*)`)합니다.
141
125
1초 후 이 프라미스가 이행되고 그 결과(`resolve`의 인수인 `result * 2`)는 두 번째 `.then`으로 전달됩니다. 두 번째 핸들러(`(**)`)는 `2`를 출력하고 동일한 과정이 반복됩니다.
142
-
=======
143
-
Here the first `.then` shows `1` and returns `new Promise(…)` in the line `(*)`. After one second it resolves, and the result (the argument of `resolve`, here it's `result * 2`) is passed on to the handler of the second `.then`. That handler is in the line `(**)`, it shows `2` and does the same thing.
144
-
>>>>>>> upstream/master
145
126
146
127
따라서 얼럿 창엔 이전 예시와 동일하게 1, 2, 4가 차례대로 출력됩니다. 다만 얼럿 창 사이에 1초의 딜레이가 생깁니다.
147
128
@@ -245,11 +226,7 @@ new Promise(resolve => resolve(1))
245
226
246
227
## fetch와 체이닝 함께 응용하기
247
228
248
-
<<<<<<< HEAD
249
229
프론트 단에선, 네트워크 요청 시 프라미스를 자주 사용합니다. 이에 관련된 예시를 살펴봅시다.
250
-
=======
251
-
In frontend programming, promises are often used for network requests. So let's see an extended example of that.
252
-
>>>>>>> upstream/master
253
230
254
231
예시에선 메서드 [fetch](info:fetch)를 사용해 원격 서버에서 사용자 정보를 가져오겠습니다. `fetch`엔 다양한 선택 매개변수가 있는데 자세한 내용은 [별도의 챕터](info:fetch)에서 다루기로 하고, 여기선 기본 문법만 사용해 보겠습니다.
0 commit comments