question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Computed properties fire when an action is emitted

See original GitHub issue

I’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:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
onionhammercommented, Mar 15, 2020

@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 Promise itself in the computed property, so if multiple things await it it will return a precomputed result if it’s already been fetched

0reactions
ctrlplusbcommented, Mar 15, 2020

Using react-query sounds like a much better fit for what you were attempting, by way of the code you showed me. 👍

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found