Skip to content

Debounce loaders #3

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

Closed
wants to merge 6 commits into from
Closed

Debounce loaders #3

wants to merge 6 commits into from

Conversation

imp-dance
Copy link
Collaborator

Should allow for debouncing of the loader to the component:

const loader = createLoader({
   queries: (queryArg) => [...], 
   queriesArg: (props) => props.queryArg,
   debounce: 200,
})

const Component = withLoader((props, data) => {
   // Will only re-run query if props have not changed in 200ms
}, loader);

Blocked: The tests are currently failing for some reason. I've published a beta-release and manually tested the functionality on CodeSandbox, and it all seems to work fine, but my local tests fail because they for some reason can't resolve the React.useState in the new useDebounce hook used within withLoader.

@imp-dance imp-dance self-assigned this Oct 28, 2022
@imp-dance
Copy link
Collaborator Author

For reference, one could achieve the same functionality today by doing something like this:

const loader = createLoader({
   queries: (arg) => {
      const debouncedArg = useDebounce(arg, 200);
      return [useQueryOne(debouncedArg.some_arg), useQueryTwo(debouncedArg.other_arg)] as const; 
   },
});

@imp-dance
Copy link
Collaborator Author

Have decided to leave this feature out for now. Might revisit it later.

@imp-dance imp-dance closed this Oct 28, 2022
@imp-dance imp-dance deleted the debounce-feat branch October 31, 2022 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant