vue-wired

0.3.0 • Public • Published

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>

gram

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

Readme

Keywords

none

Package Sidebar

Install

npm i vue-wired

Weekly Downloads

3

Version

0.3.0

License

MIT

Last publish

Collaborators

  • rem