-
Notifications
You must be signed in to change notification settings - Fork 25
Feature: Debounced/delayed Loading #11
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Not sure where the reducer/update function is headed, but we'll find out, I suppose.
It works, but now the intersection logic is not the same. Scrolling until inView is true, and then up, triggers the promise cancelation. This is undesirable. We want the image to keep loading as long as it stays on the screen. Oddly, scrolling past the image, and it being in view, still lets it load without canceling (as intendeed). Another difference is that loading only commences once the image is fully in view, rather than on the margin.
Added: - debugActions: logs actions in dev, warns and logs in prod - debounceDurationMs: whether, and how much to debounce loading, 0 by default, so no change to v1. Added codepath to make it so. - Provisional changes.md document with API compatibility - Various TODOs and cleanup tasks
Also add a note to hopefully remember to destructure next time :)
If we set declaration: true, then typescript (specifically rpt2, Rollup's TS plugin) fails with a cryptic path error. This is filed under microsoft/TypeScript#25047. Curiously, this does not happen on master, and I have vaguely traced it back to unionize and the fact that it does fancy type exports, which we partially re-export here. We would have to manually emit a declaration file, which is not hard tbh, but a bit annoying. Even funnier, webpack has no issue building in storybook, but that might be because it does not emit declarations anyway. Steps: - Get declaration file from master, add to repository, and copy to dist/ upon build; - See if massaging our exports fixes it; - Wait for TS :/
The Elm/JS/Redux/React-Component fusion is complete. The reducer is now a pure function, because it only describes side-effects, and does not execute them. The logic is really nice to read there.
Because of the "path undefined" bug, we have to run `tsc` separately, to get the definitions and copy them over.
Expose it under 'Loading' for backwards compatibility
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #10, and cleans up the codebase.
(See the issue for the design discussion)
Re-architect the internals to have explicit state management, in the spirit of Elm. The various state transitions go between
NotAsked -> Buffering -> NotAsked | Loading -> LoadingSuccess | LoadingError
, with actions for Buffering, Going In/Out of view, Loading results etc.External API:
An optional
debounceDurationMs
prop.