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

set.has does not work well with pagination #60

Closed
ilyavf opened this issue Jul 8, 2017 · 3 comments
Closed

set.has does not work well with pagination #60

ilyavf opened this issue Jul 8, 2017 · 3 comments
Assignees

Comments

@ilyavf
Copy link
Contributor

ilyavf commented Jul 8, 2017

Having algebra with offsetLimit the has method does not recognize a new item as a part of the paginated set:

const algebra = new canSet.Algebra(
  canSet.props.offsetLimit('$skip', '$limit')
)
const set = { $limit: 5, $skip: 0 }
const props = { name: "My Portfolio" }
const has = algebra.has(set, props)
// -> false

This peculiarity eliminates an updated item with can-connect real-time behavior from the live list:

const portfolios = Portfolio.getList({$limit: 5, $skip: 0})
...
portfolios[0].name = "My portfolio 2"
portfolios[0].save()
...
// -> portfolios will not contain the updated instance after receiving an updated event 
// from server by the real-time behavior.
@ilyavf ilyavf self-assigned this Jul 8, 2017
ilyavf added a commit that referenced this issue Jul 8, 2017
ilyavf added a commit that referenced this issue Jul 10, 2017
@nlundquist
Copy link
Contributor

nlundquist commented Jul 19, 2017

@ilyavf wouldn't the change to ignore pagination during .has potentially cause new instances to incorrectly appear on multiple pages?

e.g you have two different widgets showing different pages of some real-time enabled type, a third widget creates (and saves) a new instance of that type. .has would return true for the sets shown by both pages, resulting in the new instance now appearing on both displayed pages.

Instead of ignoring pagination, I think .has needs to check if the id exists in the range defined by the pagination props, though I'm not sure how that would work with string or compound ids.

@nlundquist
Copy link
Contributor

nlundquist commented Jul 19, 2017

My issue #59 touches on a related id & pagination problem

@nlundquist
Copy link
Contributor

nlundquist commented Jul 27, 2017

After discussing this with Justin I believe this issue can be closed. There is no ideal generic solution for this problem and the best we can do going forward is document the behavior and allow users to implement an application specific solution for it if they desire. I'll open a new issue for that task.

#66 was created to document this behavior and a method of overriding it with an application specific implementation.

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

No branches or pull requests

2 participants