Platform
Resources
Pricing
Sign in
Get started
Tom Larkworthy
Tech Lead at Taktile. Formerly Firebase, Google
Workspace
Fork
Public
patterns
By
Tom Larkworthy
Edited
Mar 23, 2024
12 stars
3
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
viewof
config
=
Inputs
.
input
(
)
Insert cell
Insert cell
businessLogic
=
{
yield
htl
.
svg
`<svg style="position: fixed;top:0px;height:100%" viewBox="0 0 1 1">
<rect width="1" height="1" fill=${
config
.
color
} />
</svg>`
;
await
new
Promise
(
(
resolve
)
=>
setTimeout
(
resolve
,
100
)
)
;
yield
undefined
;
}
Insert cell
Insert cell
viewof
source1
=
Inputs
.
button
(
"source1: red"
,
{
required
:
true
,
reduce
:
(
)
=>
(
{
color
:
"#f002"
}
)
}
)
Insert cell
source1
Insert cell
Insert cell
viewof
source2
=
Inputs
.
input
(
)
Insert cell
2
viewof
var2
=
Inputs
.
button
(
"var2: yellow"
,
{
required
:
true
,
reduce
:
(
)
=>
(
{
color
:
"#ff04"
}
)
}
)
Insert cell
copyVar2IntoSource2
=
{
viewof
source2
.
value
=
var2
;
viewof
source2
.
dispatchEvent
(
new
Event
(
"input"
,
{
bubbles
:
true
}
)
)
;
}
Insert cell
source2
Insert cell
Insert cell
connectSources
=
{
// Note these appear to be wired backwards!
// Source is in the target argument slot!
// Bind is not symmetrical!
Inputs
.
bind
(
viewof
source1
,
viewof
config
,
invalidation
)
;
Inputs
.
bind
(
viewof
source2
,
viewof
config
,
invalidation
)
;
}
Insert cell
Insert cell
<
style
>
code
{
border-radius
:
20
px
;
padding
:
4
px
;
background-color
:
#f5f5f5
;
}
</
style
>
Insert cell
import
{
footer
}
from
"@tomlarkworthy/footer"
Insert cell
footer
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
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
config
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
businessLogic
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
source1
Add comment
Copy import
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
source2
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
var2
Show 2 comments
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
copyVar2IntoSource2
Add comment
Copy import
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
connectSources
Add comment
Copy import
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
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML