vue3-async-computed

3.0.0 • Public • Published

vue3-async-computed

This Vue 3 plugin allows you to create computed properties that are computed asynchronously.

import * as Vue from 'vue';
import * as AsyncComputed from 'vue3-async-computed';

const asyncComputed = AsyncComputed.createPlugin({ ref: Vue.ref });

Vue.createApp({

    data() {
        return {
            userID: 1,
        }
    },

}).use(asyncComputed, {

    async profile(result) {
        result.value = `loading profile for user ${this.userID}...`;
        const response = await fetch(`https://httpbin.org/get?userID=${this.userID}`);
        const data = await response.json();
        result.value = data;
    },

}).mount('#app');

And then, in HTML:

<div>{{ userID }}: {{ profile }}</div>

Install

Install using npm install vue3-async-computed

Examples

  • Basic example, the app displays price information for any selected crypto currency: JSFiddle

Todo

Describe how to approach manual re-calculation of the async computed properties. Provide an example.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
3.0.0114latest

Version History

VersionDownloads (Last 7 Days)Published
3.0.0114
2.0.25
2.0.13
1.0.13
1.0.03

Package Sidebar

Install

npm i vue3-async-computed

Weekly Downloads

128

Version

3.0.0

License

ISC

Unpacked Size

2.85 kB

Total Files

3

Last publish

Collaborators

  • andriika