Skip to content

@ngrx/signals/entity: Replace idKey with selectId #4392

@markostanimirovic

Description

@markostanimirovic

Which @ngrx/* package(s) are relevant/related to the feature request?

signals

Information

To allow defining entity identifier from multiple properties, but also for consistency with @ngrx/entity, idKey will be replaced with selectId.

Before:

const TodosStore = signalStore(
  withEntities<Todo>(),
  withMethods((store) => ({
    addTodo(todo: Todo): void {
      patchState(store, addEntity(todo, { idKey: '_id' }));
    },
  })
);

After:

const selectId = (todo: Todo) => todo._id;

const TodosStore = signalStore(
  withEntities<Todo>(),
  withMethods((store) => ({
    addTodo(todo: Todo): void {
      patchState(store, addEntity(todo, { selectId }));
    },
  })
);

Describe any alternatives/workarounds you're currently using

No response

I would be willing to submit a PR to fix this issue

  • Yes
  • No

Metadata

Metadata

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions