0.3.0 • Published 7 years ago

vue-wired v0.3.0

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

vue-wired

NPM version NPM downloads CircleCI donate

Inspired by wiretie.

Install

yarn add vue-wired

Usage

Instead of writing:

<template>
  <div>{{ loading ? 'Loading...' : user.name }}</div>
</template>

<script>
export default {
  data() {
    return {
      loading: true,
      user: null
    }
  },
  created() {
    Promise.resolve({ name: 'EGOIST' }) // mock API call
      .then(user => {
        this.user = user
        this.loading = false
      })
  }
}
</script>

You write:

<template>
  <div>{{ pending.user ? 'Loading...' : user.name }}</div>
</template>

<script>
import wired from 'vue-wired'

export default wired({
  user: Promise.resolve({ name: 'EGOIST' }),
  // Use a function if you want to access component instance
  // via `this` or `vm` in arrow function
  // user: vm => Promise.resolve({ name: 'EGOIST' })
})({ /* Component */ })
</script>

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Author

vue-wired © egoist, Released under the MIT License. Authored and maintained by egoist with help from contributors (list).

egoistian.com · GitHub @egoist · Twitter @rem_rin_rin

0.3.0

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.0

7 years ago