Skip to content

Commit

Permalink
feat(query): fix readme and streamline provider
Browse files Browse the repository at this point in the history
  • Loading branch information
Giordano Paruccini committed Jan 23, 2024
1 parent 338781c commit 49e3d1a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 19 deletions.
18 changes: 8 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,21 +321,19 @@ const withFunctionalFactory: QueryClientConfigFn = () => {
const notificationService = inject(NotificationService);

return {
queryCache: new QueryCache({
queryCache: new QueryCache({
onError: (error: Error) => notificationService.notifyError(error),
}),
defaultOptions: {
queries: {
staleTime: 3000,
},
defaultOptions: {
queries: {
staleTime: 3000,
},
};
}
},
};
};

bootstrapApplication(AppComponent, {
providers: [
provideQueryClientOptions(withFunctionalQuery),
],
providers: [provideQueryClientOptions(withFunctionalFactory)],
});
```

Expand Down
13 changes: 4 additions & 9 deletions query/src/lib/query-client-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,9 @@ export function provideQueryClientOptions(
options: QueryClientConfig | QueryClientConfigFn,
) {
return makeEnvironmentProviders([
typeof options === 'function'
? {
provide: QUERY_CLIENT_OPTIONS,
useFactory: options,
}
: {
provide: QUERY_CLIENT_OPTIONS,
useValue: options,
},
{
provide: QUERY_CLIENT_OPTIONS,
[typeof options === 'function' ? 'useFactory' : 'useValue']: options,
} as any,
]);
}

0 comments on commit 49e3d1a

Please sign in to comment.