Platform
Resources
Pricing
Sign in
Get started
COcisuts
Sigfrid Cosmin Bonvecchio. Digital Pioneer & Smart-Cities Runner. https://www.facebook.com/pg/cocis.io/about
Workspace
Fork
Published
TUTORIALS OBSERVABLEHQ
By
COcisuts
Edited
Jan 7, 2019
Fork of
Interacting with promises as values
1 star
Insert cell
Insert cell
Promise
.
all
(
[
1
,
2
,
Promise
.
resolve
(
3
)
,
new
Promise
(
r
=>
r
(
4
)
)
]
)
Insert cell
Insert cell
{
let
x
=
new
Promise
(
(
resolve
,
reject
)
=>
{
setTimeout
(
reject
,
100
)
;
}
)
;
let
caught
=
x
.
catch
(
rejected
=>
{
return
`I'm okay, I'll get over it`
;
}
)
;
return
caught
;
}
Insert cell
Insert cell
promiseValue
=
{
let
val
=
new
Promise
(
(
resolve
,
reject
)
=>
{
setTimeout
(
(
)
=>
resolve
(
10
)
,
100
)
;
}
)
;
return
(
)
=>
val
;
}
Insert cell
{
return
promiseValue
(
)
.
then
(
p
=>
{
return
p
+
2
;
}
)
;
}
Insert cell
Purpose-built for displays of data
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Try it for free
Learn more
Compare fork
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
promiseValue
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML