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

New SortAndPage operator #917

Merged
merged 3 commits into from
Jul 7, 2024
Merged

New SortAndPage operator #917

merged 3 commits into from
Jul 7, 2024

Conversation

RolandPheasant
Copy link
Collaborator

@RolandPheasant RolandPheasant commented Jul 6, 2024

This is the following up to the SortAndVirtualize - see #888

If is an almost a direct lift of the code but using page based calculations. This is part of the drive to eliminate the Sort operator altogether, and subsequently the need to propagate the index on Change<TObject,TKey>.

Old

var pageRequests=new BehaviorSubject<IPageRequest>(new PageRequest(1, 25))

myCache 
  .Sort(myComparer)
  .Page(pageRequests)

New

var pageRequests=new BehaviorSubject<IPageRequest>(new PageRequest(1, 25))

myCache 
  .SortAndPage(myComparer, pageRequests)

There is a also a new Bind() overload to bind the results of the page response.

Additionally I have renamed SortAndBind which acts on a a virtual response to Bind() .

I just need and replace SortBy with SortByAndBind operator and I am happy to make the big version release.

Copy link
Collaborator

@JakenVeina JakenVeina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a high-level note, am I correct in reading that Virtualize and Page are just the same thing? Is there any actual difference, other than the indexing parameters?

var paramsChanged = _pageRequests.Synchronize(locker)
.DistinctUntilChanged()
// exclude dodgy params
.Where(parameters => parameters is { Page: > 0, Size: > 0 })
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this filter out some valid requests? E.G. { Page: 0, Size: 10 }? Or is Page here 1-indexed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It just ignores bad input. The other alternative would be just to throw an exception

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dang, I just re-read your comments. Page zero is not valid. Paging always starts at 1.

@RolandPheasant
Copy link
Collaborator Author

On a high-level note, am I correct in reading that Virtualize and Page are just the same thing? Is there any actual difference, other than the indexing parameters?

Indeed so. It's almost the same but I've replaced it because it already exists and we can bet our bottom dollar that someone is suing it in the wild.

@RolandPheasant RolandPheasant merged commit 01d1119 into main Jul 7, 2024
1 check passed
@RolandPheasant RolandPheasant deleted the feature/page-sort-bind branch July 7, 2024 06:48
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants