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 with a runtime argument missing when used with persistence?

See original GitHub issue

With persistence turned on our app throws Error in useStoreState: state.assets.getStakedAssetsByAddress is not a function..

It is a computed property with a runtime argument.

getStakedAssetsByAddress: computed(
  (state) => (address) => Object.values(state.stakedAssetsById[address]) || []
),

This exact issue was tackled in v4. https://github.com/ctrlplusb/easy-peasy/issues/503 Could there be a regression in v5?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ctrlplusbcommented, Sep 1, 2021

Thanks for taking the time to put this together for me.

1reaction
GollyJercommented, Sep 20, 2022

OK. I’m back with the example @ctrlplusb.

Here’s the snack. easy-peasy-persist-computed-bug

I set the store up the same way we do our production app. You will notice we build a pretty complex import structure for the store, but it’s easier to manage in the long run.

  • Pick the Android emulator.
  • When you initially load the app, with nothing persisted, it works great.
  • Then comment lines 15-23 and uncomment lines 25 - 33, hit the Save button at the top right, and reload the app.
  • You will get state.thing1.getAllTheThings is not a function.
  • Now, pick the iOS emulator.
  • App will load fine the first time.
  • Click Devices > Reload Apps at the bottom right menu of snack.
  • You will get state.thing1.getAllTheThings is not a function.
  • I think this has something to do with persistence because there isn’t persisted state when the app initially loads (no error), but there is from that point forward (with error).

And if you’re wondering why I’m not using Easy Peasy’s persistence. 👉 https://github.com/ctrlplusb/easy-peasy/issues/672 Maybe related?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bountysource
Computed properties with a runtime argument missing when used with persistence ?
Read more >
computed property set not called in Vue - Stack Overflow
The problem happens because your computed property returns an object defined nowhere but in the get handler. Whatever you try, you won't be...
Read more >
Computed properties: What am I missing? - General - Ember.JS
Hi,. The behavior of ember computed properties always suprises me and I would like to have a better understand of it. (I am...
Read more >
computed | Easy Peasy v5
Computed properties do not natively support runtime arguments, however, you can achieve this by resolving a function from your computed property ...
Read more >
Defining and Using Literal Properties
Specifically, an error occurs if the value is missing when you attempt to insert or update a record. Defining a Computed Property. In...
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