Skip to Content
자바스크립트 완벽 가이드
book

자바스크립트 완벽 가이드

by David Flanagan, Han Seon- yong
February 2022
Beginner to intermediate
784 pages
24h 53m
Korean
Insight
Content preview from 자바스크립트 완벽 가이드
JavaScript
428
13장 비동기 자바스크립트
가 이행될 때까지 기다렸다가 다음 단계를 시작합니다. 하지만
for
/
await
루프 없
이 비동기 이터레이터를 사용하면 언제든
next()
메서드를 호출할 수 있게 됩니다.
clock()
의 제너레이터 버전에서 만약
next()
메서드를 연속으로 세 번 호출했다면
거의 동시에 세 개의 프라미스가 이행될 텐데 아마 이건 의도와는 다른 결과일 것
입니다. 방금 만든 이터레이터 버전에는 그런 문제가 없습니다.
비동기 이터레이터의 장점은 비동기 이벤트나 데이터 스트림을 나타낼 수 있다
는 점입니다. 앞서 설명한
clock()
함수는 비동기성을 부여하는 핵심 요인이 우리
가 직접 만든
setTimeout()
호출이었으므로 아주 단순했습니다. 하지만 다른 비동
기 요인, 예를 들어 이벤트 핸들러 같은 것을 다뤄야 한다면 비동기 이터레이터는
훨씬 만들기 어려워집니다. 일반적으로 하나의 이벤트 핸들러 함수가 이벤트에 대
응하는데, 이터레이터의
next()
메서드는 호출될 때마다 반드시 별개의 프라미스
객체를 반환해야 하며 첫 번째 프라미스가 해석되기 전에
next()
가 여러 번 호출될
수 있기 때문입니다. 따라서 비동기 이터레이터 메서드는 비동기 이벤트가 일어나
는 순서대로 프라미스를 해석할 수 있도록 내부에 큐를 유지할
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

개발자를 위한 필수 수학

개발자를 위한 필수 수학

토머스 닐드
개발 7년차, 매니저 1일차

개발 7년차, 매니저 1일차

권원상, 한민주, 카미유 푸르니에

Publisher Resources

ISBN: 9788966263462