Skip to content

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

@arnoud-dv

Description

@arnoud-dv

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions