Skip to content

Commit 711ba0e

Browse files
authored
fix(data): correct AppEntityServices example in ngrx data doc page (#2413)
closes #2280
1 parent c9ebb06 commit 711ba0e

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

projects/ngrx.io/content/guide/data/entity-services.md

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -135,43 +135,38 @@ The following `AppEntityServices` demonstrates.
135135

136136
<code-example header="app-entity-services.ts">
137137
import { Injectable } from '@angular/core';
138-
import { Store } from '@ngrx/store';
139-
import {
140-
EntityCache,
141-
EntityCollectionServiceFactory,
142-
EntityServicesBase
143-
} from '@ngrx/data';
138+
import { EntityServicesBase, EntityServicesElements } from '@ngrx/data';
144139

145140
import { SideKick } from '../../model';
146141
import { HeroService, VillainService } from '../../services';
147142

148143
@Injectable()
149144
export class AppEntityServices extends EntityServicesBase {
150145
constructor(
151-
public readonly store: Store&lt;EntityCache&gt;,
152-
public readonly entityCollectionServiceFactory: EntityCollectionServiceFactory,
146+
elements: EntityServicesElements,
153147

154148
// Inject custom services, register them with the EntityServices, and expose in API.
155-
public readonly heroesService: HeroesService,
156-
public readonly villainsService: VillainsService
149+
readonly heroesService: HeroesService,
150+
readonly villainsService: VillainsService
157151
) {
158-
super(store, entityCollectionServiceFactory);
152+
super(elements);
159153
this.registerEntityCollectionServices([heroesService, villainsService]);
160154
}
161155

162-
// ... Additional convenience members
163-
164156
/** get the (default) SideKicks service */
165157
get sideKicksService() {
166158
return this.getEntityCollectionService&lt;SideKick&gt;('SideKick');
167159
}
168160
}
169161
</code-example>
170162

171-
`AppEntityServices` injects the two custom collection services, `HeroesService` and `VillainsService`,
172-
which it also exposes directly as convenience properties.
163+
`AppEntityService` first injects the `EntityServicesElements` helper which it passes straight through to the base class constructor.
164+
The "elements" enclose the ingredients that the base class needs to make and manage the entities you described in metadata.
165+
166+
Then it injects your two custom collection services, `HeroesService` and `VillainsService`,
167+
and exposes them directly to consumers as convenience properties for accessing those services.
173168

174-
There is no custom collections service for the `SideKick`.
169+
In this example, we don't need a custom collection service for the `SideKick` entity.
175170
The default service will do.
176171

177172
Nonetheless, we add a `sideKicksService` property that gets or creates a default service for `SideKick`.

0 commit comments

Comments
 (0)