-
-
Notifications
You must be signed in to change notification settings - Fork 40
Open
Description
Which @ngneat/query-* package(s) are relevant/releated to the feature request?
query
Description
Description
Currently, the injectQuery
function does not accept an options
object directly. This feature would enhance the usability and flexibility of the function, making it more intuitive and powerful for developers.
Current Implementation
class MyComponent {
#query = injectQuery();
getTodos() {
return this.#query({
queryKey: ['todos'] as const,
queryFn: () => {
return this.#http.get<Todo[]>('https://jsonplaceholder.typicode.com/todos');
},
});
}
}
Proposed Change
Modify the injectQuery
function to accept an options
object, allowing for more streamlined and readable code. The new usage would be similar to this:
import { injectQuery } from '@tanstack/angular-query-experimental';
...
class MyComponent {
#query = injectQuery({
queryKey: ['todos'] as const,
queryFn: () => {
return this.#http.get<Todo[]>('https://jsonplaceholder.typicode.com/todos');
},
});
}
}
Benefits
- Consistency: Aligns with other common practices of passing an options object in similar libraries.
- Readability: Enhances code readability and maintainability.
- Flexibility: Allows for easier configuration and extension of queries.
Thank you for considering this enhancement!
wizardnet972, pavankjadda and slothong
Metadata
Metadata
Assignees
Labels
No labels