SlideShare a Scribd company logo
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)

More Related Content

What's hot

Programming with Python and PostgreSQL
Programming with Python and PostgreSQLProgramming with Python and PostgreSQL
Programming with Python and PostgreSQL
Peter Eisentraut
 
Closures for Java
Closures for JavaClosures for Java
Closures for Java
nextlib
 
GeeCON Prague 2014 - Metaprogramming with Groovy
GeeCON Prague 2014 - Metaprogramming with GroovyGeeCON Prague 2014 - Metaprogramming with Groovy
GeeCON Prague 2014 - Metaprogramming with Groovy
Iván López Martín
 
Introduction kot iin
Introduction kot iinIntroduction kot iin
Introduction kot iin
Jedsada Tiwongvokul
 
Miracle of std lib
Miracle of std libMiracle of std lib
Miracle of std lib
Jedsada Tiwongvokul
 
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
Mahmoud 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 kotlin
Ahmad 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 210
Mahmoud 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 @EuroPython2014
Henning Jacobs
 
Dagger & rxjava & retrofit
Dagger & rxjava & retrofitDagger & rxjava & retrofit
Dagger & rxjava & retrofit
Ted Liang
 
Dive into kotlins coroutines
Dive into kotlins coroutinesDive into kotlins coroutines
Dive into kotlins coroutines
Freddie Wang
 
Current State of Coroutines
Current State of CoroutinesCurrent State of Coroutines
Current State of Coroutines
Guido Pio Mariotti
 
Laying Pipe with Transmogrifier
Laying Pipe with TransmogrifierLaying Pipe with Transmogrifier
Laying Pipe with Transmogrifier
Clayton Parker
 
Kotlin coroutines
Kotlin coroutines Kotlin coroutines
Kotlin coroutines
TSE-JU LIN(Louis)
 
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 NLTK
Francesco 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 Future
emptysquare
 

What's hot (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
 

Viewers also liked

모바일 무한 스크롤 개발
모바일 무한 스크롤 개발모바일 무한 스크롤 개발
모바일 무한 스크롤 개발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 - HTML5
Young-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
 

Viewers also liked (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 to Do you Promise?

Boom! Promises/A+ Was Born
Boom! Promises/A+ Was BornBoom! Promises/A+ Was Born
Boom! Promises/A+ Was Born
Domenic Denicola
 
Promises, Promises
Promises, PromisesPromises, Promises
Promises, Promises
Domenic Denicola
 
Human scaling on the front end
Human scaling on the front endHuman scaling on the front end
Human scaling on the front end
Rudy 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ß
 
React native
React nativeReact native
Programming Sideways: Asynchronous Techniques for Android
Programming Sideways: Asynchronous Techniques for AndroidProgramming Sideways: Asynchronous Techniques for Android
Programming Sideways: Asynchronous Techniques for Android
Emanuele Di Saverio
 
The State of PHPUnit
The State of PHPUnitThe State of PHPUnit
The State of PHPUnit
Edorian
 
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 Trio
Jérôme Petazzoni
 
Best Practices for Quality Code
Best Practices for Quality CodeBest Practices for Quality Code
Best Practices for Quality Code
Sercan 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 microservice
Giulio De Donato
 
2011 Pharo Roadmap explained
2011 Pharo Roadmap explained2011 Pharo Roadmap explained
2011 Pharo Roadmap explained
Pharo
 
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
C4Media
 
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)
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
 
HP Enyo
HP EnyoHP Enyo

Similar to 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
 

More from jungkees

PWA Roadshow Korea - Service Worker
PWA Roadshow Korea - Service WorkerPWA Roadshow Korea - Service Worker
PWA Roadshow Korea - Service Worker
jungkees
 
Service Worker - Reliability bits
Service Worker - Reliability bitsService Worker - Reliability bits
Service Worker - Reliability bits
jungkees
 
Samsung Internet 4.0
Samsung Internet 4.0Samsung Internet 4.0
Samsung Internet 4.0
jungkees
 
Progressive Web Apps
Progressive Web AppsProgressive Web Apps
Progressive Web Apps
jungkees
 
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
jungkees
 
Service workers 기초 및 활용 (Korean)
Service workers 기초 및 활용 (Korean)Service workers 기초 및 활용 (Korean)
Service workers 기초 및 활용 (Korean)
jungkees
 
Service workers
Service workersService workers
Service workers
jungkees
 
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
 

More from 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
 

Recently uploaded

Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 

Recently uploaded (20)

Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.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)