Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Aug 31, 2024. It is now read-only.

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

mainclass/vue3-async-computed

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

5 Commits

Repository files navigation

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.

About

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

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

AltStyle によって変換されたページ (->オリジナル) /