Angular-RU/angular-ru-sdk

๐Ÿž [BUG]: Entity State adapter - selectAll generates "this.getState is not a function" error

luchian94 opened this issue ยท 1 comments

Which @angular-ru/* package(s) are the source of the bug?

ngxs

Is this a regression?

No

Description

So I am trying to use NgxsDataEntityCollectionsRepository inside lazy loaded module but when I try to selectAll entities from store it generates "this.getState is not a function" error.

The setAll is working fine because if I inspect the state it contains all entities correctly.

I am using Angular 12 and this is my store:

`@StateRepository()
@State({
name: 'highlightedProjects',
defaults: createEntityCollections(),
})
@Injectable()
export class HighlightedProjectState extends NgxsDataEntityCollectionsRepository {
constructor(private projectService: ProjectService) {
super();
}

selectId(entity: HighlightedProject): EntityIdType {
return entity.id;
}

@action(HighlightedProjectActions.Load)
load() {
return this.projectService.getHighlightedProjects().pipe(
tap((projects) => {
this.setAll(projects);
})
);
}
}`

The selector is in another service:
highlightedProjects$ = this.store.select(this.highlightedProjectState.selectAll);

I also tried to debug it from console but it's not clear for me what's the problem, seems like getState method is missing for some reason

2022-01-12 at 19 02

Hello, please provide github repo for reproduce