Skip to content

Commit 8550dff

Browse files
committed
Async actions in computed properties
1 parent 34bc123 commit 8550dff

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ List of 300 VueJS Interview Questions
231231
|222| [What are navigation guards in vue router?](#what-are-navigation-guards-in-vue-router)|
232232
|223| [Can I use computed property in another computed property?](#can-i-use-computed-property-in-another-computed-property)|
233233
|224| [How can I use imported constant in template section?](#How-can-i-use-imported-constant-in-template-section)|
234-
|225| [](#)|
234+
|225| [Is recommended to use async for computed properties?](#is-recommended-to-use-async-for-computed-properties)|
235235
|226| [](#)|
236236
|227| [](#)|
237237
|228| [](#)|
@@ -4708,11 +4708,18 @@ List of 300 VueJS Interview Questions
47084708
47094709
**[⬆ Back to Top](#table-of-contents)**
47104710
4711-
225. ### ?
4711+
225. ### Is recommended to use async for computed properties?
4712+
No, it is not recommended. Computed properties should be synchronous. But if you still use asynchronous actions inside them, they may not work as expected and can lead to an unexpected behaviour. For example, the below usage of async/await is not recommended,
4713+
```javascript
4714+
async someComputedProperty () {
4715+
return await someFunction()
4716+
},
4717+
```
4718+
**Note:** If you still prefer to use async computed properties for some reason then you can consider using additional plugin such as `vue-async-computed`.
47124719
47134720
**[⬆ Back to Top](#table-of-contents)**
47144721
4715-
226. ### ?
4722+
226. ### What happens if you use duplicate field names?
47164723
47174724
**[⬆ Back to Top](#table-of-contents)**
47184725

0 commit comments

Comments
 (0)