Skip to content
Source
Sign inSign up
TanStack/query

Angular: injector parameter needs to be made consistent between all functions #8711

Closedarnoud-dv(GitHub profile, opens in a new tab) opened this issue 1 comment

injectMutationState accepts a custom injector through an options object:

class MyComponent {
  injector = inject(Injector);

  mutationState = injectMutationState(
    () => ({
      filters: {},
    }),
    { injector: this.injector },
  );
}

The other functions do this directly via a parameter:

class MyComponent {
  injector = inject(Injector);

  query = injectQuery(
    () => ({
      queryKey: ["posts"],
      queryFn: () =>
        fetch("https://jsonplaceholder.typicode.com/posts").then((res) =>
          res.json(),
        ),
    }),
    this.injector,
  );
}

Includes injectDevtoolsPanel in the Angular devtools package. This should be made consistent. While passing an options object as parameter is a bit more verbose it matches Angular APIs such as effect and allows adding more options in the future.

  1. arnoud-dv(GitHub profile, opens in a new tab) added labelspackage: angular-query

  2. arnoud-dv(GitHub profile, opens in a new tab) added labelspackage: angular-query-experimental

  3. arnoud-dv(GitHub profile, opens in a new tab) added labelspackage: angular-query-devtools

  4. arnoud-dv(GitHub profile, opens in a new tab) added labelspackage: angular-query-devtools-experimental

  5. Hi @arnoud-dv. I've created a draft PR :)

Sign in to join this conversation.