Skip to content

Instantly share code, notes, and snippets.

@natew
Last active February 14, 2016 19:02
Show Gist options
  • Save natew/6bfde79a70a0be32be85 to your computer and use it in GitHub Desktop.
Save natew/6bfde79a70a0be32be85 to your computer and use it in GitHub Desktop.
view Gallery {
let data
(async () =>
data = await fetch.data($`
User {
pictures(first: 10) {
count, pictures
}
}
`)
)()
<loading if={!data} />
<pictures repeat={data.pictures}>
</pictures>
}
view Gallery {
let data
fetch.data($`
User {
pictures(first: 10) {
count, pictures
}
}
`).then(_ => data = _)
<loading if={!data} />
<pictures repeat={data.pictures}>
</pictures>
}
view Gallery {
let data = await fetch.data($`
User {
pictures(first: 10) {
count, pictures
}
}
`)
// downside is how do you show loading state (what shows while loading)
<loading if={!data} />
<pictures repeat={data.pictures}>
</pictures>
}
view Gallery {
fragment data = `
User {
pictures(first: 10) {
count, pictures
}
}
`
// downside is now you have a variable changing but no good way to react to it, unless you do view.render()
<loading if={!data} />
<pictures repeat={data.pictures}>
</pictures>
}
@fragment( `
User {
pictures(first: 10) {
count, pictures
}
}
`)
view Gallery {
prop data
// downside is now you have a variable changing but no good way to react to it, unless you do view.render()
<loading if={!data} />
<pictures repeat={data.pictures}>
</pictures>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment