Computed properties fire when an action is emitted
See original GitHub issueI’m attempting to use computed properties to preserve fetch results and createContextStore;
...
getSomething1: computed((state) => fetch("something1", state.date)),
getSomething2: computed((state) => fetch("something2", state.date)),
getSomething3: computed((state) => fetch("something3", state.date)),
...
I’m then consuming only 1 of the computed properties; getSomething1, everything works perfectly until I change the state of ‘date’, then all three getSomething (1, 2, 3) fire off fetches even though I’m only using the first one anywhere.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
3 Anti-Patterns to avoid in Vue.js - Binarcode
Computed properties in Vue.js are a very convenient way to manage state that depends on other state. Computed properties should be used to...
Read more >Ember computed property depending on service property not ...
Computed properties, by default, observe any changes made to the properties they depend on, and are dynamically updated when they're called.
Read more >Computed Properties and Watchers - Vue.js
A computed property will only re-evaluate when some of its reactive dependencies have changed. This means as long as message has not changed,...
Read more >Async Computed Properties > The Delightful World of Vue
We currently have a filteredProducts computed property, which computes the correct array of Products to use based on the searchTerm and products ....
Read more >Examining Update Events with Computed Properties in Vue.js
We can see the lifecycle in action by using watch functions to observe when the data in an instance changes, and the beforeUpdate...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@ctrlplusb I’ve already switched to using react-query to cache results, but I’m definitely open to recommendations on how I can better use easy-peasy to do this stuff 😉
My initial goal was to store the
Promiseitself in the computed property, so if multiple thingsawaitit it will return a precomputed result if it’s already been fetchedUsing
react-querysounds like a much better fit for what you were attempting, by way of the code you showed me. 👍