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

Add global config #44

Closed
5 of 6 tasks
steaks opened this issue Oct 26, 2024 · 1 comment
Closed
5 of 6 tasks

Add global config #44

steaks opened this issue Oct 26, 2024 · 1 comment

Comments

@steaks
Copy link
Owner

steaks commented Oct 26, 2024

Summary

Add a global config so devs can write options like retry overrides once rather than on every query.

Acceptance Criteria

  • Determine if we need to treat query vs. effect configs separately
  • Determine which QueryOptions should be in global config
  • Determine which EffectOptions should be in global config
  • Create global config
  • Document global config
  • Implement global config into effects and queries

Notes

Some prototyping

export interface GlobalQueryOptions {
  readonly debounce?: number;
  readonly retry?: number | ((attempt: number, error: any) => boolean);
  readonly retryDelay?: (attempt: number) => number;
}

export interface GlobalOptions {
  readonly query: GlobalQueryOptions;
}
export const config = (c: GlobalOptions) => { /* ... */ };

import {config} from "leo-query";

config({
  query: {
    debounce: 1000,
    retry: (attempt: number, error: any) => {
      if (error instanceof Response && error.status === 401) {
        return false;
      }
      if (error && error.status === 401) {
        return false;
      }
      return attempt < 5;
    }
  }
});
@steaks
Copy link
Owner Author

steaks commented Nov 11, 2024

TODO - going to add documentation about the global config in a future task

@steaks steaks closed this as completed Nov 11, 2024
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

1 participant