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

자바스크립트 완벽 가이드

by David Flanagan, Han Seon- yong
February 2022
Beginner to intermediate
784 pages
24h 53m
Korean
Insight
Content preview from 자바스크립트 완벽 가이드
the De󼴩nitive Guide
397
13.2 프라미스
13.2
󼧓󺱋󻃇󻝳
클라이언트 사이드와 서버 사이드 자바스크립트 환경의 콜백과 이벤트 기반 비동
기 프로그래밍을 예제로 살펴봤으니 이제 비동기 프로그래밍을 단순화하도록 설계
된 코어 기능인
프라미스
프라미스를 소개할 차례입니다.
프라미스는 비동기 작업의 결과를 나타내는 객체입니다. 결과가 준비됐을 수도
있고 준비되지 않았을 수도 있는데, 프라미스 API는 이를 의도적으로 막연하게 표
현합니다. 프라미스의 값을 동기적으로 가져올 수 있는 방법은 존재하지 않습니다.
값이 준비됐을 때 콜백 함수를 호출하도록 프라미스에 요청할 수 있을 뿐입니다.
앞 절의
getText()
함수 같은 비동기 API를 프라미스 기반으로 만들면서 콜백 인자
는 생략하고 대신 프라미스 객체를 반환하도록 만들고 싶다고 합시다. 호출자가 이
프라미스 객체에 콜백을 등록하면 콜백은 비동기 작업이 끝났을 때 호출됩니다.
따라서 프라미스를 아주 단순하게 말한다면 콜백을 사용하는 새로운 방법이라
고 할 수도 있습니다. 그렇게만 이해하고 있어도 프라미스를 유용하게 쓸 수 있습
니다. 콜백 기반 비동기 프로그래밍의 심각한 문제는 콜백 안에 콜백이, 그 안에 또
콜백이 이어지는 형태가 계속되면 너무 심하게 들여쓰기 되어 코드를 읽기 어려워
지는, 소위
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