Skip to content

Instantly share code, notes, and snippets.

@superMDguy
Last active October 9, 2018 23:51
Show Gist options
  • Select an option

  • Save superMDguy/5f9427d02eb2f754f94bdd1393a39885 to your computer and use it in GitHub Desktop.

Select an option

Save superMDguy/5f9427d02eb2f754f94bdd1393a39885 to your computer and use it in GitHub Desktop.
import tuxi from 'tuxi'
import api from './api'
const articlesTask = tuxi.task(api.fetchArticles)
// ⚡ Fire the api call
articlesTask.start()
// The task is immediately set to pending
console.log(articlesTask.pending) // true
// 🌀 The spinning property has a configurable delay
setTimeout(() => console.log(articlesTask.spinning), 1500) // true
// After a while...
console.log(articlesTask.hasValue) // true
console.log(articlesTask.value) // ['New Planet Discovered!', '17 Surprising Superfoods!', ...]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment