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

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

Open
arnoud-dv opened this issue Feb 26, 2025 · 1 comment · May be fixed by #8776
Open

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

arnoud-dv opened this issue Feb 26, 2025 · 1 comment · May be fixed by #8776

Comments

@arnoud-dv
Copy link
Collaborator

arnoud-dv commented Feb 26, 2025

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.

dominicbachmann added a commit to dominicbachmann/query that referenced this issue Mar 8, 2025
…object instead of an injector

change query functions to accept an options object instead of an injector so that it matches angular APIs such as effect and allows adding more options in the future.

BREAKING CHANGE: The injector option has been replaced with an options object. The injector can now be provided with the options object.
Closes TanStack#8711
dominicbachmann added a commit to dominicbachmann/query that referenced this issue Mar 8, 2025
…object instead of an injector

change query functions to accept an options object instead of an injector so that it matches angular APIs such as effect and allows adding more options in the future.

BREAKING CHANGE: The injector option has been replaced with an options object. The injector can now be provided with the options object.
Closes TanStack#8711
@dominicbachmann
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment