Build an infinite-scroll feed
Load cursor-based feed pages as a sentinel enters the viewport without duplicate requests or items.Description
Requirements
The solution exports the required InfiniteScrollFeed API from the editable module.
Initial page works deterministically for the documented normal, boundary, and repeated-use scenarios.
Sentinel load works deterministically for the documented normal, boundary, and repeated-use scenarios.
Single flight works deterministically for the documented normal, boundary, and repeated-use scenarios.
Append deduplicate works deterministically for the documented normal, boundary, and repeated-use scenarios.
Terminal state works deterministically for the documented normal, boundary, and repeated-use scenarios.
Subscriptions, timers, observers, and global listeners are released when they are no longer needed.
Overlapping pages
Page one ends with item b; page two starts with item b
Item b appears once and later unique items are appended
Stable IDs prevent duplicate rows when an API returns overlapping cursor windows.
Constraints
Use IntersectionObserver rather than scroll pollingNever issue more than one page request at a timeAbort or ignore work after unmount
Hints
Hint 1
Model loading, next cursor, and terminal state separately.
Hint 2
Guard the observer callback before starting a request because one intersection may produce several notifications.
Hint 3
Append through an ID-aware merge and disconnect the observer once no next cursor remains.