Skip to content

Instantly share code, notes, and snippets.

@superMDguy
Created October 9, 2018 23:31
Show Gist options
  • Select an option

  • Save superMDguy/0823d28b1addfd77d910752e443d8adf to your computer and use it in GitHub Desktop.

Select an option

Save superMDguy/0823d28b1addfd77d910752e443d8adf to your computer and use it in GitHub Desktop.
<template>
<div class="wrapper">
<div class="empty-message" v-if="articlesTask.empty">
No articles
</div>
<div class="spinner" v-if="articlesTask.spinning">
Loading articles...
</div>
<div class="error-message" v-if="articlesTask.error">
{{ articlesTask.error.message }}
</div>
<ul v-if="articlesTask.hasValue">
<li v-for="article in articles">
{{ article.title }}
</li>
</ul>
</div>
</template>
<script>
import tuxi from 'tuxi'
import api from './api'
export default {
data() {
return {
articlesTask: tuxi.task(api.fetchArticles)
}
},
computed: {
articles() {
return this.articlesTask.value
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment