Last active
February 14, 2016 19:02
-
-
Save natew/6bfde79a70a0be32be85 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
view Gallery { | |
let data | |
(async () => | |
data = await fetch.data($` | |
User { | |
pictures(first: 10) { | |
count, pictures | |
} | |
} | |
`) | |
)() | |
<loading if={!data} /> | |
<pictures repeat={data.pictures}> | |
</pictures> | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
view Gallery { | |
let data | |
fetch.data($` | |
User { | |
pictures(first: 10) { | |
count, pictures | |
} | |
} | |
`).then(_ => data = _) | |
<loading if={!data} /> | |
<pictures repeat={data.pictures}> | |
</pictures> | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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