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.

[Persistence] data doesn't get fetched in use until I trigger an action (entity.set())

See original GitHub issue

Describe the bug In order to try this out, I set up a simple todo list on Codesandbox.io. Everything worked fine until I introduce the persistence plugin. It doesn’t fetch the persisted state when the component mounts unless I trigger the entity.set() function.

To Reproduce Steps to reproduce the behaviour:

  1. link to a sandbox to demonstrate this: https://codesandbox.io/s/loving-worker-vei0p?file=/src/App.tsx
  2. add a couple of todos from the input field
  3. click reload in the codesandbox mini browser, only the initial state will show up.

Expected behaviour todo items are supposed to be fetched when components mounts (on load)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
arnelenerocommented, May 3, 2021

Yesterday, I held a workshop where I shared simpler-state with my community. They really share the same excitement as I do. However, someone asked me a very valid question;

Apart from the developer experience, what other benefit does simpler-state has. i.e performance and benchmark. Has any test been carried out? @arnelenero

I ran some open-source tests that were originally meant to test state managers in Concurrent Mode, but it also measures execution times. Happy to report these positive results:

All figures are execution times in milliseconds (lower is better)

| External Events | Transition | Auto Increment – | – | – | – SimpleR State | 2885 | 2319 | 2746 React-redux | 3231 | 2335 | 3143 Redux + use-mutable-source | 3286 | 2403 | 3225 Recoil | 3209 | 2562 * | 3105 Use-subscription | 3205 | 2413 | 3242 Zustand | 3178 | 2340 | 3126 Jotai | 3210 | 2429 | 3230 Valtio | 3217 | 2338 | 3305 React Sweet State | 4180 | 3276 | 3150 Effector | 4174 | 3140 | 3104

(*) Recoil failed the transition test for some reason tests were based on: https://github.com/dai-shi/will-this-react-global-state-work-in-concurrent-mode

So SimpleR State is not only developer-friendly, but also superlatively fast. I don’t really like comparing with other libraries out there, especially the “giants”—it simply wasn’t the goal of the library—but since someone asked… 🤣

1reaction
jalasemcommented, May 2, 2021

Yesterday, I held a workshop where I shared simpler-state with my community. They really share the same excitement as I do. However, someone asked me a very valid question;

Apart from the developer experience, what other benefit does simpler-state has. i.e performance and benchmark. Has any test been carried out? @arnelenero

Read more comments on GitHub >

github_iconTop Results From Across the Web

Refresh and fetch an entity after save (JPA/Spring Data ...
Use Refresh directly in SomethingResource (Assuming Something is an ... EAGER , the entity should have the property attribute initialized.
Read more >
Hibernate's persist(), save(), merge() and update()
You can use the methods persist and save to store a new entity and the methods merge and update to store the changes...
Read more >
Querying JPA Entities with JPQL and Native SQL - Oracle
Learn how to take advantage of the Java Persistence query language and native SQL when querying over JPA entities. In Java EE, the...
Read more >
Redux Essentials, Part 8: RTK Query Advanced Patterns
RTK Query allows multiple components to subscribe to the same data, and will ensure that each unique set of data is only fetched...
Read more >
Hibernate ORM 6.1.6.Final User Guide - Red Hat on GitHub
Basic collection mapping; 2.2.44. ... Dynamic fetching via Jakarta Persistence entity graph ... Use Hibernate and report any bugs or issues you find....
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