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

Draft: params.clones #24

Closed
wants to merge 17 commits into from
Closed

Conversation

fratzinger
Copy link
Collaborator

@fratzinger fratzinger commented Dec 10, 2021

  • feat(findInStore): add params.clones
  • feat: findInStore with params.clones
  • feat: getFromStore with params.clones
  • fix(findInStore): don't readd picked values
  • refactor(findInStore): move _.values to items / temps getters -> micro perf
  • refactor: simplify addOrUpdate
  • docs: add params.clones
  • tests
  • fix: add idField to getAnyId
  • feat: add micro-optimization getters (itemsAndTemps, itemsAndClones, itemsTempsAndClones, operators)
  • perf: findInStore micro-optimized
  • fix: model.reset() working again
  • add resetClone renaming to the 'What's Different from Feathers-Vuex' section
  • add a test for clone.reset() @fratzinger
  • add new getters to docs
  • add clone.clone() to the 'What's Different from Feathers-Vuex' section

Because feathers-pinia uses clones over copies consistently, I decided to call it params.clones. It's a (small) breaking change compared to feathers-vuex.

Also I also added variable pickedValues because otherwise if $select is used, the items get added and added to the store. That's also problematic for clones, because the cloned $selected values would overwrite the itemsById values. I'm happy to discuss this.

closes #30

fratzinger added 2 commits December 10, 2021 13:19
- why was it as it was?
- feat: findInStore with params.clones
- fix: don't readd picked values
- refactor: move _.values to Object.values
@marshallswain
Copy link
Owner

This is looking solid. Could you add some tests to make the spec official?

@fratzinger
Copy link
Collaborator Author

Currently at it ;)

@fratzinger
Copy link
Collaborator Author

I think it's ready now. I also added params.clones support for getFromStore. This diverges from findInStore a little bit.
In findInStore we have temps: true and clones: true. In getFromStore we don't have temps: true. Instead we can use getFromStore(__tempId).
So there are two behaviors:

  • findInStore({ query: {}, temps: false, clones: true } returns just items with id and and if existent, their cloned items
  • For getInStore there no option to set temps: false

Maybe we can just leave it like that. Maybe we should add support for temps: false for getFromStore.

@fratzinger
Copy link
Collaborator Author

We could even do more micro optimizations, if we have a itemsAndTemps, itemsWithClones, itemsAndTempsWithClones store getters. In findInStore we could use:

let values
if (!params.temps && !params.clones) {
  values = this.items
} else if (params.temps && !params.clones) {
  values = this.itemsAndTemps
} else if (!params.temps && params.clones) {
  values = this.itemsWithClones
} else {
  values = this.itemsAndTempsWithClones
}

The more a findInStore is used with temps or clones, the more the micro optimization pays off because the concatenation of items, temps and clones is cached.
What do you think?

@marshallswain
Copy link
Owner

marshallswain commented Jan 19, 2022 via email

@fratzinger
Copy link
Collaborator Author

Started it and went down the rabbit hole in #30. Need decisions first over there (see the todos at the bottom of the issue). When decisions are clear, I'll add the other todos to this PR.

@fratzinger
Copy link
Collaborator Author

Reason for #30 was a failing test. I don't know what to do. There is a quirk about __isClone being false and undefined. Please @marshallswain could you have a look?:

@marshallswain
Copy link
Owner

@fratzinger, I'm still open to adding this feature. Since this PR is so far outdated, now, I'm going to go ahead and close it and we can re-branch from v2.

@marshallswain
Copy link
Owner

I went ahead and added the querying part of the feature through findInStore and getFromStore: https://github.com/marshallswain/feathers-pinia/releases/tag/v2.0.0-pre.11

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

Successfully merging this pull request may close these issues.

clone & reset handling different than feathers-vuex
3 participants