You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently it’s hard to detect the end of loop, using cursor for pagination.
Command to run:
AvaProtocol/ava-sdk-js#45 npx jest tests/getExecutions.test.ts -t "options.cursor works as pagination" (this test need modification for this issue)
If the cursor points to the id of the last element, we will need a hasMore: true to indicate whether there are more, otherwise we can’t tell if there is more.
In the current implementation, the cursor returns "" at the end, so it’s the cursor of the next element, which doesn’t exsit. However, in client’s code, if they take "" and pass it back into the loop, the list result will start over, retuning the 1st element of the list.
A working case would be, the current iteration takes the returned cursor value, and pass it into the next iteration, and the list retuns empty result.
If we renames the cursor to nextCursor, empty string could be the indicator that we have reached the end of the list; however, we need to fix the empty string causing the list to start over problem. Basically, the beginning of the list should be distinctive from the end.
Could we refer to some standard design for the implementation of the cursor?
The text was updated successfully, but these errors were encountered:
Problem
Currently it’s hard to detect the end of loop, using cursor for pagination.
Command to run:
AvaProtocol/ava-sdk-js#45
npx jest tests/getExecutions.test.ts -t "options.cursor works as pagination"
(this test need modification for this issue)If the cursor points to the id of the last element, we will need a
hasMore: true
to indicate whether there are more, otherwise we can’t tell if there is more.In the current implementation, the cursor returns "" at the end, so it’s the cursor of the next element, which doesn’t exsit. However, in client’s code, if they take "" and pass it back into the loop, the list result will start over, retuning the 1st element of the list.
A working case would be, the current iteration takes the returned cursor value, and pass it into the next iteration, and the list retuns empty result.
If we renames the
cursor
tonextCursor
, empty string could be the indicator that we have reached the end of the list; however, we need to fix the empty string causing the list to start over problem. Basically, the beginning of the list should be distinctive from the end.Could we refer to some standard design for the implementation of the cursor?
The text was updated successfully, but these errors were encountered: