Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keeping reactivity intact #659

Closed
2 of 3 tasks
Juice10 opened this issue Dec 3, 2022 · 9 comments
Closed
2 of 3 tasks

Keeping reactivity intact #659

Juice10 opened this issue Dec 3, 2022 · 9 comments
Labels
enhancement New feature or request

Comments

@Juice10
Copy link

Juice10 commented Dec 3, 2022

Describe the feature

Keeping reactivity is incredible important to keep applications performant. However Pinia-ORM (& Vuex-ORM) generate a completely new javascript object for every single model in a collection everytime a mutation is triggered for something in that collection.

This has meant we’ve been forced to move away from Vuex-ORM for our app.

It’s great to see the progress on Pinia-ORM! Maybe this something Pinia-ORM could fix?

more info; vuex-orm/vuex-orm#746

Additional information

  • Would you be willing to help implement this feature?
  • Could this feature be implemented as a module?

Final checks

@CodeDredd CodeDredd added enhancement New feature or request and removed pending triage labels Dec 4, 2022
@CodeDredd
Copy link
Owner

That sound like something to have.
Would be really awesome if you or other can help on this. I am not yet sure how to implement it.
First thing what poped to my mind was to use the cache system already built in. But it doesn't feel right somehow....so i try to keep thinking....

@Juice10
Copy link
Author

Juice10 commented Dec 4, 2022

Initially I was planning to just build this for Vuex-ORM 0.x since that is what we used. But looking at the code I didn’t know how to make it happen. And then looking at 1.x I was even more confused. Willingness to help is here. But know how is lacking for me as well

@CodeDredd
Copy link
Owner

@Juice10 I solved it. Took me some thinking but now the one performance bug will go away 😉

CodeDredd added a commit that referenced this issue Dec 6, 2022
* perf(pinia-orm-659): Save hydrated models if not updated

* refactor(pinia-orm): typo

closes #659
@Juice10
Copy link
Author

Juice10 commented Dec 6, 2022

Wow @CodeDredd this is incredibly cool! What a great job!

@Juice10
Copy link
Author

Juice10 commented Dec 6, 2022

Is there any way to get around the JSON comparison? JSON.stringify(savedHydratedModel) === JSON.stringify(hydratedModel)
Maybe even return the savedHydratedModel before recreating the model again (as long as there are no updates)? That would make this super super fast.

Especially if you have large models the JSON stringification can be quite painful.

@CodeDredd
Copy link
Owner

@Juice10 puhhh i try to make this better....but i already searched ways comparing hydrated opjects. i needed that to be 100% sure that i don't return a saved hydratedobject for a query where you need an update. Yes i included an "update" but since pinia-orm also uses internally queries i was uncertain what happens at runtime.

@Juice10
Copy link
Author

Juice10 commented Dec 6, 2022

Thanks @CodeDredd you're a hero. I tried naively making the changes I suggested but that does break quite a lot
image

@CodeDredd
Copy link
Owner

CodeDredd commented Dec 6, 2022

yeah...god save the unit tests....thats the reason why i compare the hydrated objects. ^^

@Juice10 Maybe there is better way. If you find one that would be awesome.
I did the impossible part getting it to work....now it's your turn to improve it... hehehe 😁 🚀

@CodeDredd
Copy link
Owner

@Juice10 well i found for you the better way 😉 .... now you owe me a cup of ☕ 😜

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants