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

What are the constrains on the slice passed to connectionFromArraySlice? #81

Open
jnak opened this issue Apr 30, 2016 · 2 comments
Open

Comments

@jnak
Copy link

jnak commented Apr 30, 2016

Hello guys!

It seems to me than to pass a valid slice to connectionFromArraySlice you basically need to know the start offset and end offset to make the slice bigger. Do you agree?

If yes, I'm happy to extract this piece into its own function and add tests :)

Cheers

@wincent
Copy link
Contributor

wincent commented Apr 30, 2016

I'm not really sure I understand what you're asking here, although I see you followed up with #82. Perhaps we should discuss there instead?

@jnak
Copy link
Author

jnak commented Apr 30, 2016

Sorry wrote that before going to bed... It is not specifically related to #82.

My point is that connectionFromArraySlice expects a slice that contains the elements it needs to populate the page. But you cannot know what those elements are without first going through the pagination algorithm. And right now the pagination algorithm is implemented directly in connectionFromArraySlice (vs factored out in its own function).

This leaves with 2 options when constructing the slice to pass to connectionFromArraySlice:

  1. Come up with a heuristics / strategy to easily compute offsetStart and offsetEnd before calling connectionFromArraySlice,
  2. Call connectionFromArraySlice with dummy data to extract offsetStart and offsetEnd, generate a slice based on these params and call again connectionFromArraySlice with the slice

Is this clearer?

If yes, happy to factor out this pagination algorithm (for a bounded array) into its own function :)

@jnak jnak changed the title What are the constrain on the slice passed to connectionFromArraySlice? What are the constrains on the slice passed to connectionFromArraySlice? May 2, 2016
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