Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up
for free
Promises, Futures, and the Shape of Your Code
Greg Heo
May 21, 2018
Technology
0
16
Promises, Futures, and the Shape of Your Code
Greg Heo
May 21, 2018
Tweet
Share
More Decks by Greg Heo
See All by Greg Heo
gregheo
0
65
gregheo
0
45
gregheo
0
150
gregheo
0
28
gregheo
0
490
gregheo
0
62
gregheo
0
34
gregheo
0
96
gregheo
3
160
Other Decks in Technology
See All in Technology
yosuke_matsuura
PRO
0
3.2k
hirosys
0
110
ama_ch
0
3.3k
nkjzm
1
810
satoshirobatofujimoto
0
110
clustervr
0
190
pinboro
1
1.4k
clustervr
0
200
greymd
0
600
kappa4
4
2k
neo_analytics
0
980
satotakeshi
2
410
Featured
See All Featured
tenderlove
52
3.4k
vanstee
116
4.8k
jcasabona
7
520
jmmastey
8
530
moore
125
21k
mojombo
358
62k
deanohume
295
27k
philhawksworth
190
17k
sstephenson
144
12k
davidbonilla
69
3.5k
erikaheidi
13
4.2k
andyhume
62
3.3k
Transcript
@gregheo C1 Mobile Summit
++++++++[>++++[>++>+ ++>+++>+<<<<-]>+>+>- >>+[<]<-]>>.>---.+++ ++++..+++.>>.<-.<.++ +.------.--------.>> +.>++.
None
None
None
None
None
!
networker.beginRequest(.read, success: { data in })
networker.beginRequest(.read, success: { data in parser.parseRaw(data) { result in }
})
networker.beginRequest(.read, success: { data in parser.parseRaw(data) { result in archiver.materialize(from:
result) { objects in } } })
networker.beginRequest(.read, success: { data in parser.parseRaw(data) { result in archiver.materialize(from:
result) { objects in dataStore.save(objects) { status in } } } })
networker.beginRequest(.read, success: { data in parser.parseRaw(data) { result in archiver.materialize(from:
result) { objects in dataStore.save(objects) { status in print("Save success!") } } } }) print("Hello 1") print("Hello 2")
⏰#
None
A B C X Y Z
networker.beginRequest(.read, success: { data in parser.parseRaw(data) { result in archiver.materialize(from:
result) { objects in dataStore.save(objects) { status in print("Save success!") } } } }) print("Hello 1") print("Hello 2")
⏰#
networker.beginRequest(.read, success: { data in parser.parseRaw(data) { result in archiver.materialize(from:
result) { objects in dataStore.save(objects) { status in print("Save success!") } } } })
Clojure
Future
(defn square [x] (* x x) )
(defn square [x] (future (* x x)) )
(defn saveToDisk [data] (future ( ... )) )
saveToDisk future completed? cancelled? value
@myFuture (deref myFuture)
A X Y future B C D (deref future)
Future
Promise
@myPromise (deref myPromise)
getValue promise realized? value promise deliver
Promise
❓
%&