SlideShare una empresa de Scribd logo
1 de 18
Descargar para leer sin conexión
DO YOU PROMISE?
Jungkee Song / @jungkees

Documented using reveal.js
JUNGKEE SONG
Twitter: @jungkees
Google+: +JungkeeSong

W3C HTML5 KOREAN INTEREST GROUP
Join
IN THE SPOTLIGHT
CONTENT
JavaScript Runtime Model
Events and Callbacks
Hello Promises
Promises guarantee
Is it ready for you?
Promises the real thing
Practises and References
Web standards Promise
#extendthewebforward
JAVASCRIPT RUNTIME MODEL
Run-to-completion and Event loop
A downside
“If a message takes too long to complete, the
web application is unable to process user
interactions like click or scroll.”
So, never block it
“A good practice to follow is to make message
processing short and if possible cut down one
message into several messages.”
EVENTS
User gesture
Click, Scroll, Touch...
Resource loading
DOMContentLoaded, load...
Handler must be set before an event is dispatched

CALLBACKS
IndexedDB , Geolocation , XMLHttpRequest , basically all the
platform APIs.
Callbacks in the APIs are not consistent
Hard to follow the flow when a callback ties with other
callbacks
HELLO PROMISES
From W3C TAG Promise Guide
“A promise is an object that represents the
eventual result of a single asynchronous
operation. They can be returned from
asynchronous functions, thus allowing
consumers to not only queue up callbacks to be
called when the operation succeeds or fails, but
also to manipulate the returned promise object,
opening up a variety of possibilities.”
HELLO PROMISES
Construct a Promise
vrpoie=nwPoiersle)
a rms
e rms(eovr;
fnto rsle(eov,rjc){
ucin eovrrsle eet
/ D yu ts n hr
/ o or ak o ee
i (/ tig aedn O * ){
f
* hns r oe K /
rslersl)
eov(eut;
}es {
le
rjc(ro)
eeterr;
}
}

Use the Promise
poiete(nufle,oRjce)
rms.hnoFlild neetd;
fnto oFlildrsl){
ucin nufle(eut
cnoelg"ucee:"+rsl)
osl.o(scedd
eut;
}
fnto oRjce(ro){
ucin neetderr
cnoeerrerr;
osl.ro(ro)
}
HELLO PROMISES
Rejection handling
poiete(neie,fnto(ro){
rms.hnudfnd ucinerr
cnoeerrerr;
osl.ro(ro)
};
)

Catch - An idiomatic shorthand
poiecthfnto(ro){
rms.ac(ucinerr
cnoeerrerr;
osl.ro(ro)
};
)
PROMISES API REFERENCE
PROMISES GUARANTEE
Only one of onFulfilled or onRejected will be called
onFulfilled is called with a single fulfillment value
onRejected is called with a single rejection reason
If the promise is already settled, the hanlder will still be called
once you attach them
The handler will always be called asynchronously
IS IT READY FOR YOU?
Firefox 29
“Promise them that thanks to @nikhilcutshort
promises will be shipping in Firefox 29. :-)” Anne van Kesteren
Chrome 32 (Partial) / 33 (Full)
Opera 20
IE?
Yup! You can rock it with a polyfill
NOW LET'S ADDRESS A REAL ISSUE
Deep nested callbacks
d.pn..f( {
boe(. n)
d.olcin.. f( {
bcleto(.. n)
d.ur(...f( {
bqey... n)
xrsn(;
h.ed)
xrola =f( {
h.nod
n)
}
;
};
)
};
)
};
)
PROMISES THE REAL THING
Chaining - Transforming values
Poiersle1.hnfnto(au){
rms.eov()te(ucinvle
cnoelgvle;/ 1
osl.o(au) /
rtr vle+10
eun au
0;
}.hnfnto(au){
)te(ucinvle
cnoelg"eh ti i js "+vle;/ Ya,ti i js 11
osl.o(Ya, hs s ut
au) / eh hs s ut 0
};
)

Chaining - Queuing async actions
PoierslesmRsl)te(ucinrsl){
rms.eov(oeeut.hnfnto(eut
rtr armsDigetakrsl)
eun PoieonNxTs(eut;
}.hnfnto(eut {
)te(ucinrsl)
rtr aeAohrrmsDigoeakrsl)
eun YtntePoieonMrTs(eut;
}.hnfnto(eut {
)te(ucinrsl)
cnoelg"lih!Tak.Igt" rsl)
osl.o(Argt hns
o , eut;
}.ac(ucinerr {
)cthfnto(ro)
cnoeerr"an Teewssmtigwogi tecan";
osl.ro(Dr! hr a oehn rn n h hi.)
};
)

Error handling in the chain: Promise rejections skip forward to
the next "then" with a rejection callback!
PROMISES THE REAL THING
Write your chain of actions idiomatically!
PoierslesmRsl)te(ucinrsl){
rms.eov(oeeut.hnfnto(eut
rtr armsDigetakrsl)
eun PoieonNxTs(eut;
}.ac(ucinerr {
)cthfnto(ro)
rtr rtyhFieTigneoe)
eun erTealdhnOcMr(;
}.hnfnto(eut {
)te(ucinrsl)
rtr aeAohrrmsDigoeakrsl)
eun YtntePoieonMrTs(eut;
} fnto(ro){
, ucinerr
rtr Poierjc(ro)
eun rms.eeterr;
}.hnfnto(eut {
)te(ucinrsl)
cnoelg"lih!Tak.Igt" rsl)
osl.o(Argt hns
o , eut;
}.ac(ucinerr {
)cthfnto(ro)
cnoeerr"an Teewssmtigwogi tecan";
osl.ro(Dr! hr a oehn rn n h hi.)
};
)
PRACTISES AND REFERENCES
Html5Rocks (Korean) - Jake Archibald
MDN - Mozilla
ES6 Promise - TC39
Promises, Promises - Domenic Denicola
WEB STANDARDS WITH PROMISES
Spec athors are guided to use it
The movement is getting faster!
Examples
Quota Management API
Before
After
Network Service Discovery API
Before
After
Service Workers
Heavy use of Promises
#EXTENDTHEWEBFORWARD
“Promises are one of the best examples of the extensible web
principles, where collaborative developer work informs web
standards.” - Domenic Denicola (Co-editor of Promises/A+,
Member of W3C TAG)

Más contenido relacionado

La actualidad más candente

Programming with Python and PostgreSQL
Programming with Python and PostgreSQLProgramming with Python and PostgreSQL
Programming with Python and PostgreSQLPeter Eisentraut
 
Closures for Java
Closures for JavaClosures for Java
Closures for Javanextlib
 
GeeCON Prague 2014 - Metaprogramming with Groovy
GeeCON Prague 2014 - Metaprogramming with GroovyGeeCON Prague 2014 - Metaprogramming with Groovy
GeeCON Prague 2014 - Metaprogramming with GroovyIván López Martín
 
The Ring programming language version 1.7 book - Part 7 of 196
The Ring programming language version 1.7 book - Part 7 of 196The Ring programming language version 1.7 book - Part 7 of 196
The Ring programming language version 1.7 book - Part 7 of 196Mahmoud Samir Fayed
 
Dts x dicoding #2 memulai pemrograman kotlin
Dts x dicoding #2 memulai pemrograman kotlinDts x dicoding #2 memulai pemrograman kotlin
Dts x dicoding #2 memulai pemrograman kotlinAhmad Arif Faizin
 
The Ring programming language version 1.9 book - Part 48 of 210
The Ring programming language version 1.9 book - Part 48 of 210The Ring programming language version 1.9 book - Part 48 of 210
The Ring programming language version 1.9 book - Part 48 of 210Mahmoud Samir Fayed
 
"PostgreSQL and Python" Lightning Talk @EuroPython2014
"PostgreSQL and Python" Lightning Talk @EuroPython2014"PostgreSQL and Python" Lightning Talk @EuroPython2014
"PostgreSQL and Python" Lightning Talk @EuroPython2014Henning Jacobs
 
Dagger & rxjava & retrofit
Dagger & rxjava & retrofitDagger & rxjava & retrofit
Dagger & rxjava & retrofitTed Liang
 
Dive into kotlins coroutines
Dive into kotlins coroutinesDive into kotlins coroutines
Dive into kotlins coroutinesFreddie Wang
 
Laying Pipe with Transmogrifier
Laying Pipe with TransmogrifierLaying Pipe with Transmogrifier
Laying Pipe with TransmogrifierClayton Parker
 
What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)Pavlo Baron
 
GeeCON 2013 - EJB application guided by tests
GeeCON 2013 - EJB application guided by testsGeeCON 2013 - EJB application guided by tests
GeeCON 2013 - EJB application guided by testsJakub Marchwicki
 
Basic NLP with Python and NLTK
Basic NLP with Python and NLTKBasic NLP with Python and NLTK
Basic NLP with Python and NLTKFrancesco Bruni
 
5. Ввод-вывод, доступ к файловой системе
5. Ввод-вывод, доступ к файловой системе5. Ввод-вывод, доступ к файловой системе
5. Ввод-вывод, доступ к файловой системеDEVTYPE
 
Jggug 2010 330 Grails 1.3 観察
Jggug 2010 330 Grails 1.3 観察Jggug 2010 330 Grails 1.3 観察
Jggug 2010 330 Grails 1.3 観察Tsuyoshi Yamamoto
 
Python Coroutines, Present and Future
Python Coroutines, Present and FuturePython Coroutines, Present and Future
Python Coroutines, Present and Futureemptysquare
 

La actualidad más candente (20)

Programming with Python and PostgreSQL
Programming with Python and PostgreSQLProgramming with Python and PostgreSQL
Programming with Python and PostgreSQL
 
Closures for Java
Closures for JavaClosures for Java
Closures for Java
 
GeeCON Prague 2014 - Metaprogramming with Groovy
GeeCON Prague 2014 - Metaprogramming with GroovyGeeCON Prague 2014 - Metaprogramming with Groovy
GeeCON Prague 2014 - Metaprogramming with Groovy
 
Introduction kot iin
Introduction kot iinIntroduction kot iin
Introduction kot iin
 
Miracle of std lib
Miracle of std libMiracle of std lib
Miracle of std lib
 
The Ring programming language version 1.7 book - Part 7 of 196
The Ring programming language version 1.7 book - Part 7 of 196The Ring programming language version 1.7 book - Part 7 of 196
The Ring programming language version 1.7 book - Part 7 of 196
 
Dts x dicoding #2 memulai pemrograman kotlin
Dts x dicoding #2 memulai pemrograman kotlinDts x dicoding #2 memulai pemrograman kotlin
Dts x dicoding #2 memulai pemrograman kotlin
 
The Ring programming language version 1.9 book - Part 48 of 210
The Ring programming language version 1.9 book - Part 48 of 210The Ring programming language version 1.9 book - Part 48 of 210
The Ring programming language version 1.9 book - Part 48 of 210
 
"PostgreSQL and Python" Lightning Talk @EuroPython2014
"PostgreSQL and Python" Lightning Talk @EuroPython2014"PostgreSQL and Python" Lightning Talk @EuroPython2014
"PostgreSQL and Python" Lightning Talk @EuroPython2014
 
Dagger & rxjava & retrofit
Dagger & rxjava & retrofitDagger & rxjava & retrofit
Dagger & rxjava & retrofit
 
Dive into kotlins coroutines
Dive into kotlins coroutinesDive into kotlins coroutines
Dive into kotlins coroutines
 
Current State of Coroutines
Current State of CoroutinesCurrent State of Coroutines
Current State of Coroutines
 
Laying Pipe with Transmogrifier
Laying Pipe with TransmogrifierLaying Pipe with Transmogrifier
Laying Pipe with Transmogrifier
 
Kotlin coroutines
Kotlin coroutines Kotlin coroutines
Kotlin coroutines
 
What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)
 
GeeCON 2013 - EJB application guided by tests
GeeCON 2013 - EJB application guided by testsGeeCON 2013 - EJB application guided by tests
GeeCON 2013 - EJB application guided by tests
 
Basic NLP with Python and NLTK
Basic NLP with Python and NLTKBasic NLP with Python and NLTK
Basic NLP with Python and NLTK
 
5. Ввод-вывод, доступ к файловой системе
5. Ввод-вывод, доступ к файловой системе5. Ввод-вывод, доступ к файловой системе
5. Ввод-вывод, доступ к файловой системе
 
Jggug 2010 330 Grails 1.3 観察
Jggug 2010 330 Grails 1.3 観察Jggug 2010 330 Grails 1.3 観察
Jggug 2010 330 Grails 1.3 観察
 
Python Coroutines, Present and Future
Python Coroutines, Present and FuturePython Coroutines, Present and Future
Python Coroutines, Present and Future
 

Destacado

모바일 무한 스크롤 개발
모바일 무한 스크롤 개발모바일 무한 스크롤 개발
모바일 무한 스크롤 개발NAVER D2
 
개발자를 위한 웹표준 & 웹접근성이야기
개발자를 위한 웹표준 & 웹접근성이야기개발자를 위한 웹표준 & 웹접근성이야기
개발자를 위한 웹표준 & 웹접근성이야기NAVER D2
 
JavaScript로 오픈소스를 해보자. bsJS
JavaScript로 오픈소스를 해보자. bsJSJavaScript로 오픈소스를 해보자. bsJS
JavaScript로 오픈소스를 해보자. bsJSNAVER D2
 
Front-End 개발의 괜찮은 선택 ES6 & React
Front-End 개발의 괜찮은 선택  ES6 & ReactFront-End 개발의 괜찮은 선택  ES6 & React
Front-End 개발의 괜찮은 선택 ES6 & React지수 윤
 
Angularjs 도입 선택 가이드
Angularjs 도입 선택 가이드Angularjs 도입 선택 가이드
Angularjs 도입 선택 가이드NAVER D2
 
웹 Front-End 실무 이야기
웹 Front-End 실무 이야기웹 Front-End 실무 이야기
웹 Front-End 실무 이야기JinKwon Lee
 
[D2 오픈세미나]5.html5 api 테트리스게임_이진권
[D2 오픈세미나]5.html5 api 테트리스게임_이진권[D2 오픈세미나]5.html5 api 테트리스게임_이진권
[D2 오픈세미나]5.html5 api 테트리스게임_이진권NAVER D2
 
[D2 오픈세미나]2.browser engine 이형욱_20140523
[D2 오픈세미나]2.browser engine 이형욱_20140523[D2 오픈세미나]2.browser engine 이형욱_20140523
[D2 오픈세미나]2.browser engine 이형욱_20140523NAVER D2
 
[D2 오픈세미나]4.진보된개발환경 주우영
[D2 오픈세미나]4.진보된개발환경 주우영[D2 오픈세미나]4.진보된개발환경 주우영
[D2 오픈세미나]4.진보된개발환경 주우영NAVER D2
 
[D2 오픈세미나]1.html5 api 옥상훈
[D2 오픈세미나]1.html5 api 옥상훈[D2 오픈세미나]1.html5 api 옥상훈
[D2 오픈세미나]1.html5 api 옥상훈NAVER D2
 
[D2 오픈세미나]3.자바스크립트mean스택 김태훈
[D2 오픈세미나]3.자바스크립트mean스택 김태훈[D2 오픈세미나]3.자바스크립트mean스택 김태훈
[D2 오픈세미나]3.자바스크립트mean스택 김태훈NAVER D2
 
ECMAScript 6의 새로운 것들!
ECMAScript 6의 새로운 것들!ECMAScript 6의 새로운 것들!
ECMAScript 6의 새로운 것들!WooYoung Cho
 
Front-end Development Process - 어디까지 개선할 수 있나
Front-end Development Process - 어디까지 개선할 수 있나Front-end Development Process - 어디까지 개선할 수 있나
Front-end Development Process - 어디까지 개선할 수 있나JeongHun Byeon
 
자바카페 프론트엔드스터디 E01 - HTML5
자바카페 프론트엔드스터디 E01 - HTML5자바카페 프론트엔드스터디 E01 - HTML5
자바카페 프론트엔드스터디 E01 - HTML5Young-Beom Rhee
 
JavaScript 비동기 프로그래밍 집중 탐구 - 조유성님
JavaScript 비동기 프로그래밍 집중 탐구 - 조유성님JavaScript 비동기 프로그래밍 집중 탐구 - 조유성님
JavaScript 비동기 프로그래밍 집중 탐구 - 조유성님NAVER D2
 
텀 프로젝트에서 제품 프로젝트로 - 성준영님
텀 프로젝트에서 제품 프로젝트로 - 성준영님텀 프로젝트에서 제품 프로젝트로 - 성준영님
텀 프로젝트에서 제품 프로젝트로 - 성준영님NAVER D2
 
데이터분석과통계2 - 최재걸님
데이터분석과통계2 - 최재걸님데이터분석과통계2 - 최재걸님
데이터분석과통계2 - 최재걸님NAVER D2
 
Papago/N2MT 개발이야기
Papago/N2MT 개발이야기Papago/N2MT 개발이야기
Papago/N2MT 개발이야기NAVER D2
 
프론트엔드 애니메이션의 정수
프론트엔드 애니메이션의 정수프론트엔드 애니메이션의 정수
프론트엔드 애니메이션의 정수jeong seok yang
 
[2014널리세미나] 사용자 측면에서의 한국형 웹 콘텐츠 지침
[2014널리세미나] 사용자 측면에서의 한국형 웹 콘텐츠 지침[2014널리세미나] 사용자 측면에서의 한국형 웹 콘텐츠 지침
[2014널리세미나] 사용자 측면에서의 한국형 웹 콘텐츠 지침Nts Nuli
 

Destacado (20)

모바일 무한 스크롤 개발
모바일 무한 스크롤 개발모바일 무한 스크롤 개발
모바일 무한 스크롤 개발
 
개발자를 위한 웹표준 & 웹접근성이야기
개발자를 위한 웹표준 & 웹접근성이야기개발자를 위한 웹표준 & 웹접근성이야기
개발자를 위한 웹표준 & 웹접근성이야기
 
JavaScript로 오픈소스를 해보자. bsJS
JavaScript로 오픈소스를 해보자. bsJSJavaScript로 오픈소스를 해보자. bsJS
JavaScript로 오픈소스를 해보자. bsJS
 
Front-End 개발의 괜찮은 선택 ES6 & React
Front-End 개발의 괜찮은 선택  ES6 & ReactFront-End 개발의 괜찮은 선택  ES6 & React
Front-End 개발의 괜찮은 선택 ES6 & React
 
Angularjs 도입 선택 가이드
Angularjs 도입 선택 가이드Angularjs 도입 선택 가이드
Angularjs 도입 선택 가이드
 
웹 Front-End 실무 이야기
웹 Front-End 실무 이야기웹 Front-End 실무 이야기
웹 Front-End 실무 이야기
 
[D2 오픈세미나]5.html5 api 테트리스게임_이진권
[D2 오픈세미나]5.html5 api 테트리스게임_이진권[D2 오픈세미나]5.html5 api 테트리스게임_이진권
[D2 오픈세미나]5.html5 api 테트리스게임_이진권
 
[D2 오픈세미나]2.browser engine 이형욱_20140523
[D2 오픈세미나]2.browser engine 이형욱_20140523[D2 오픈세미나]2.browser engine 이형욱_20140523
[D2 오픈세미나]2.browser engine 이형욱_20140523
 
[D2 오픈세미나]4.진보된개발환경 주우영
[D2 오픈세미나]4.진보된개발환경 주우영[D2 오픈세미나]4.진보된개발환경 주우영
[D2 오픈세미나]4.진보된개발환경 주우영
 
[D2 오픈세미나]1.html5 api 옥상훈
[D2 오픈세미나]1.html5 api 옥상훈[D2 오픈세미나]1.html5 api 옥상훈
[D2 오픈세미나]1.html5 api 옥상훈
 
[D2 오픈세미나]3.자바스크립트mean스택 김태훈
[D2 오픈세미나]3.자바스크립트mean스택 김태훈[D2 오픈세미나]3.자바스크립트mean스택 김태훈
[D2 오픈세미나]3.자바스크립트mean스택 김태훈
 
ECMAScript 6의 새로운 것들!
ECMAScript 6의 새로운 것들!ECMAScript 6의 새로운 것들!
ECMAScript 6의 새로운 것들!
 
Front-end Development Process - 어디까지 개선할 수 있나
Front-end Development Process - 어디까지 개선할 수 있나Front-end Development Process - 어디까지 개선할 수 있나
Front-end Development Process - 어디까지 개선할 수 있나
 
자바카페 프론트엔드스터디 E01 - HTML5
자바카페 프론트엔드스터디 E01 - HTML5자바카페 프론트엔드스터디 E01 - HTML5
자바카페 프론트엔드스터디 E01 - HTML5
 
JavaScript 비동기 프로그래밍 집중 탐구 - 조유성님
JavaScript 비동기 프로그래밍 집중 탐구 - 조유성님JavaScript 비동기 프로그래밍 집중 탐구 - 조유성님
JavaScript 비동기 프로그래밍 집중 탐구 - 조유성님
 
텀 프로젝트에서 제품 프로젝트로 - 성준영님
텀 프로젝트에서 제품 프로젝트로 - 성준영님텀 프로젝트에서 제품 프로젝트로 - 성준영님
텀 프로젝트에서 제품 프로젝트로 - 성준영님
 
데이터분석과통계2 - 최재걸님
데이터분석과통계2 - 최재걸님데이터분석과통계2 - 최재걸님
데이터분석과통계2 - 최재걸님
 
Papago/N2MT 개발이야기
Papago/N2MT 개발이야기Papago/N2MT 개발이야기
Papago/N2MT 개발이야기
 
프론트엔드 애니메이션의 정수
프론트엔드 애니메이션의 정수프론트엔드 애니메이션의 정수
프론트엔드 애니메이션의 정수
 
[2014널리세미나] 사용자 측면에서의 한국형 웹 콘텐츠 지침
[2014널리세미나] 사용자 측면에서의 한국형 웹 콘텐츠 지침[2014널리세미나] 사용자 측면에서의 한국형 웹 콘텐츠 지침
[2014널리세미나] 사용자 측면에서의 한국형 웹 콘텐츠 지침
 

Similar a Do you Promise?

Boom! Promises/A+ Was Born
Boom! Promises/A+ Was BornBoom! Promises/A+ Was Born
Boom! Promises/A+ Was BornDomenic Denicola
 
Human scaling on the front end
Human scaling on the front endHuman scaling on the front end
Human scaling on the front endRudy Rigot
 
The event-driven nature of javascript – IPC2012
The event-driven nature of javascript – IPC2012The event-driven nature of javascript – IPC2012
The event-driven nature of javascript – IPC2012Martin Schuhfuß
 
Programming Sideways: Asynchronous Techniques for Android
Programming Sideways: Asynchronous Techniques for AndroidProgramming Sideways: Asynchronous Techniques for Android
Programming Sideways: Asynchronous Techniques for AndroidEmanuele Di Saverio
 
The State of PHPUnit
The State of PHPUnitThe State of PHPUnit
The State of PHPUnitEdorian
 
The State of PHPUnit
The State of PHPUnitThe State of PHPUnit
The State of PHPUnitEdorian
 
Containers, Docker, and Microservices: the Terrific Trio
Containers, Docker, and Microservices: the Terrific TrioContainers, Docker, and Microservices: the Terrific Trio
Containers, Docker, and Microservices: the Terrific TrioJérôme Petazzoni
 
Best Practices for Quality Code
Best Practices for Quality CodeBest Practices for Quality Code
Best Practices for Quality CodeSercan Degirmenci
 
The state of PHPUnit
The state of PHPUnitThe state of PHPUnit
The state of PHPUnitEdorian
 
WWX14 speech : Justin Donaldson "Promhx : Cross-platform Promises and Reactiv...
WWX14 speech : Justin Donaldson "Promhx : Cross-platform Promises and Reactiv...WWX14 speech : Justin Donaldson "Promhx : Cross-platform Promises and Reactiv...
WWX14 speech : Justin Donaldson "Promhx : Cross-platform Promises and Reactiv...antopensource
 
Import golang; struct microservice
Import golang; struct microserviceImport golang; struct microservice
Import golang; struct microserviceGiulio De Donato
 
2011 Pharo Roadmap explained
2011 Pharo Roadmap explained2011 Pharo Roadmap explained
2011 Pharo Roadmap explainedPharo
 
Digital Publishing for Scale: The Economist and Go
Digital Publishing for Scale: The Economist and GoDigital Publishing for Scale: The Economist and Go
Digital Publishing for Scale: The Economist and GoC4Media
 
5 x HTML5 worth using in APEX (5)
5 x HTML5 worth using in APEX (5)5 x HTML5 worth using in APEX (5)
5 x HTML5 worth using in APEX (5)Christian Rokitta
 
function* - ES6, generators, and all that (JSRomandie meetup, February 2014)
function* - ES6, generators, and all that (JSRomandie meetup, February 2014)function* - ES6, generators, and all that (JSRomandie meetup, February 2014)
function* - ES6, generators, and all that (JSRomandie meetup, February 2014)Igalia
 

Similar a Do you Promise? (20)

Boom! Promises/A+ Was Born
Boom! Promises/A+ Was BornBoom! Promises/A+ Was Born
Boom! Promises/A+ Was Born
 
Promises, Promises
Promises, PromisesPromises, Promises
Promises, Promises
 
Human scaling on the front end
Human scaling on the front endHuman scaling on the front end
Human scaling on the front end
 
The event-driven nature of javascript – IPC2012
The event-driven nature of javascript – IPC2012The event-driven nature of javascript – IPC2012
The event-driven nature of javascript – IPC2012
 
React native
React nativeReact native
React native
 
Programming Sideways: Asynchronous Techniques for Android
Programming Sideways: Asynchronous Techniques for AndroidProgramming Sideways: Asynchronous Techniques for Android
Programming Sideways: Asynchronous Techniques for Android
 
The State of PHPUnit
The State of PHPUnitThe State of PHPUnit
The State of PHPUnit
 
The State of PHPUnit
The State of PHPUnitThe State of PHPUnit
The State of PHPUnit
 
Containers, Docker, and Microservices: the Terrific Trio
Containers, Docker, and Microservices: the Terrific TrioContainers, Docker, and Microservices: the Terrific Trio
Containers, Docker, and Microservices: the Terrific Trio
 
All of Javascript
All of JavascriptAll of Javascript
All of Javascript
 
Best Practices for Quality Code
Best Practices for Quality CodeBest Practices for Quality Code
Best Practices for Quality Code
 
The state of PHPUnit
The state of PHPUnitThe state of PHPUnit
The state of PHPUnit
 
WWX14 speech : Justin Donaldson "Promhx : Cross-platform Promises and Reactiv...
WWX14 speech : Justin Donaldson "Promhx : Cross-platform Promises and Reactiv...WWX14 speech : Justin Donaldson "Promhx : Cross-platform Promises and Reactiv...
WWX14 speech : Justin Donaldson "Promhx : Cross-platform Promises and Reactiv...
 
Import golang; struct microservice
Import golang; struct microserviceImport golang; struct microservice
Import golang; struct microservice
 
2011 Pharo Roadmap explained
2011 Pharo Roadmap explained2011 Pharo Roadmap explained
2011 Pharo Roadmap explained
 
Digital Publishing for Scale: The Economist and Go
Digital Publishing for Scale: The Economist and GoDigital Publishing for Scale: The Economist and Go
Digital Publishing for Scale: The Economist and Go
 
Domains!
Domains!Domains!
Domains!
 
5 x HTML5 worth using in APEX (5)
5 x HTML5 worth using in APEX (5)5 x HTML5 worth using in APEX (5)
5 x HTML5 worth using in APEX (5)
 
function* - ES6, generators, and all that (JSRomandie meetup, February 2014)
function* - ES6, generators, and all that (JSRomandie meetup, February 2014)function* - ES6, generators, and all that (JSRomandie meetup, February 2014)
function* - ES6, generators, and all that (JSRomandie meetup, February 2014)
 
HP Enyo
HP EnyoHP Enyo
HP Enyo
 

Más de jungkees

PWA Roadshow Korea - Service Worker
PWA Roadshow Korea - Service WorkerPWA Roadshow Korea - Service Worker
PWA Roadshow Korea - Service Workerjungkees
 
Service Worker - Reliability bits
Service Worker - Reliability bitsService Worker - Reliability bits
Service Worker - Reliability bitsjungkees
 
Samsung Internet 4.0
Samsung Internet 4.0Samsung Internet 4.0
Samsung Internet 4.0jungkees
 
Progressive Web Apps
Progressive Web AppsProgressive Web Apps
Progressive Web Appsjungkees
 
Service Worker at W3C HTML5 Conference in Seoul on the 9th of Dec 2015
Service Worker at W3C HTML5 Conference in Seoul on the 9th of Dec 2015Service Worker at W3C HTML5 Conference in Seoul on the 9th of Dec 2015
Service Worker at W3C HTML5 Conference in Seoul on the 9th of Dec 2015jungkees
 
Service workers 기초 및 활용 (Korean)
Service workers 기초 및 활용 (Korean)Service workers 기초 및 활용 (Korean)
Service workers 기초 및 활용 (Korean)jungkees
 
Service workers
Service workersService workers
Service workersjungkees
 
Progress Events Web Apps F2F at San Jose
Progress Events Web Apps F2F at San JoseProgress Events Web Apps F2F at San Jose
Progress Events Web Apps F2F at San Josejungkees
 
XHR Web APps F2F at San Jose
XHR Web APps F2F at San JoseXHR Web APps F2F at San Jose
XHR Web APps F2F at San Josejungkees
 

Más de jungkees (9)

PWA Roadshow Korea - Service Worker
PWA Roadshow Korea - Service WorkerPWA Roadshow Korea - Service Worker
PWA Roadshow Korea - Service Worker
 
Service Worker - Reliability bits
Service Worker - Reliability bitsService Worker - Reliability bits
Service Worker - Reliability bits
 
Samsung Internet 4.0
Samsung Internet 4.0Samsung Internet 4.0
Samsung Internet 4.0
 
Progressive Web Apps
Progressive Web AppsProgressive Web Apps
Progressive Web Apps
 
Service Worker at W3C HTML5 Conference in Seoul on the 9th of Dec 2015
Service Worker at W3C HTML5 Conference in Seoul on the 9th of Dec 2015Service Worker at W3C HTML5 Conference in Seoul on the 9th of Dec 2015
Service Worker at W3C HTML5 Conference in Seoul on the 9th of Dec 2015
 
Service workers 기초 및 활용 (Korean)
Service workers 기초 및 활용 (Korean)Service workers 기초 및 활용 (Korean)
Service workers 기초 및 활용 (Korean)
 
Service workers
Service workersService workers
Service workers
 
Progress Events Web Apps F2F at San Jose
Progress Events Web Apps F2F at San JoseProgress Events Web Apps F2F at San Jose
Progress Events Web Apps F2F at San Jose
 
XHR Web APps F2F at San Jose
XHR Web APps F2F at San JoseXHR Web APps F2F at San Jose
XHR Web APps F2F at San Jose
 

Último

Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 

Último (20)

DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 

Do you Promise?

  • 1. DO YOU PROMISE? Jungkee Song / @jungkees Documented using reveal.js
  • 2. JUNGKEE SONG Twitter: @jungkees Google+: +JungkeeSong W3C HTML5 KOREAN INTEREST GROUP Join
  • 4. CONTENT JavaScript Runtime Model Events and Callbacks Hello Promises Promises guarantee Is it ready for you? Promises the real thing Practises and References Web standards Promise #extendthewebforward
  • 5. JAVASCRIPT RUNTIME MODEL Run-to-completion and Event loop A downside “If a message takes too long to complete, the web application is unable to process user interactions like click or scroll.” So, never block it “A good practice to follow is to make message processing short and if possible cut down one message into several messages.”
  • 6. EVENTS User gesture Click, Scroll, Touch... Resource loading DOMContentLoaded, load... Handler must be set before an event is dispatched CALLBACKS IndexedDB , Geolocation , XMLHttpRequest , basically all the platform APIs. Callbacks in the APIs are not consistent Hard to follow the flow when a callback ties with other callbacks
  • 7. HELLO PROMISES From W3C TAG Promise Guide “A promise is an object that represents the eventual result of a single asynchronous operation. They can be returned from asynchronous functions, thus allowing consumers to not only queue up callbacks to be called when the operation succeeds or fails, but also to manipulate the returned promise object, opening up a variety of possibilities.”
  • 8. HELLO PROMISES Construct a Promise vrpoie=nwPoiersle) a rms e rms(eovr; fnto rsle(eov,rjc){ ucin eovrrsle eet / D yu ts n hr / o or ak o ee i (/ tig aedn O * ){ f * hns r oe K / rslersl) eov(eut; }es { le rjc(ro) eeterr; } } Use the Promise poiete(nufle,oRjce) rms.hnoFlild neetd; fnto oFlildrsl){ ucin nufle(eut cnoelg"ucee:"+rsl) osl.o(scedd eut; } fnto oRjce(ro){ ucin neetderr cnoeerrerr; osl.ro(ro) }
  • 9. HELLO PROMISES Rejection handling poiete(neie,fnto(ro){ rms.hnudfnd ucinerr cnoeerrerr; osl.ro(ro) }; ) Catch - An idiomatic shorthand poiecthfnto(ro){ rms.ac(ucinerr cnoeerrerr; osl.ro(ro) }; )
  • 11. PROMISES GUARANTEE Only one of onFulfilled or onRejected will be called onFulfilled is called with a single fulfillment value onRejected is called with a single rejection reason If the promise is already settled, the hanlder will still be called once you attach them The handler will always be called asynchronously
  • 12. IS IT READY FOR YOU? Firefox 29 “Promise them that thanks to @nikhilcutshort promises will be shipping in Firefox 29. :-)” Anne van Kesteren Chrome 32 (Partial) / 33 (Full) Opera 20 IE? Yup! You can rock it with a polyfill
  • 13. NOW LET'S ADDRESS A REAL ISSUE Deep nested callbacks d.pn..f( { boe(. n) d.olcin.. f( { bcleto(.. n) d.ur(...f( { bqey... n) xrsn(; h.ed) xrola =f( { h.nod n) } ; }; ) }; ) }; )
  • 14. PROMISES THE REAL THING Chaining - Transforming values Poiersle1.hnfnto(au){ rms.eov()te(ucinvle cnoelgvle;/ 1 osl.o(au) / rtr vle+10 eun au 0; }.hnfnto(au){ )te(ucinvle cnoelg"eh ti i js "+vle;/ Ya,ti i js 11 osl.o(Ya, hs s ut au) / eh hs s ut 0 }; ) Chaining - Queuing async actions PoierslesmRsl)te(ucinrsl){ rms.eov(oeeut.hnfnto(eut rtr armsDigetakrsl) eun PoieonNxTs(eut; }.hnfnto(eut { )te(ucinrsl) rtr aeAohrrmsDigoeakrsl) eun YtntePoieonMrTs(eut; }.hnfnto(eut { )te(ucinrsl) cnoelg"lih!Tak.Igt" rsl) osl.o(Argt hns o , eut; }.ac(ucinerr { )cthfnto(ro) cnoeerr"an Teewssmtigwogi tecan"; osl.ro(Dr! hr a oehn rn n h hi.) }; ) Error handling in the chain: Promise rejections skip forward to the next "then" with a rejection callback!
  • 15. PROMISES THE REAL THING Write your chain of actions idiomatically! PoierslesmRsl)te(ucinrsl){ rms.eov(oeeut.hnfnto(eut rtr armsDigetakrsl) eun PoieonNxTs(eut; }.ac(ucinerr { )cthfnto(ro) rtr rtyhFieTigneoe) eun erTealdhnOcMr(; }.hnfnto(eut { )te(ucinrsl) rtr aeAohrrmsDigoeakrsl) eun YtntePoieonMrTs(eut; } fnto(ro){ , ucinerr rtr Poierjc(ro) eun rms.eeterr; }.hnfnto(eut { )te(ucinrsl) cnoelg"lih!Tak.Igt" rsl) osl.o(Argt hns o , eut; }.ac(ucinerr { )cthfnto(ro) cnoeerr"an Teewssmtigwogi tecan"; osl.ro(Dr! hr a oehn rn n h hi.) }; )
  • 16. PRACTISES AND REFERENCES Html5Rocks (Korean) - Jake Archibald MDN - Mozilla ES6 Promise - TC39 Promises, Promises - Domenic Denicola
  • 17. WEB STANDARDS WITH PROMISES Spec athors are guided to use it The movement is getting faster! Examples Quota Management API Before After Network Service Discovery API Before After Service Workers Heavy use of Promises
  • 18. #EXTENDTHEWEBFORWARD “Promises are one of the best examples of the extensible web principles, where collaborative developer work informs web standards.” - Domenic Denicola (Co-editor of Promises/A+, Member of W3C TAG)