@@ -135,43 +135,38 @@ The following `AppEntityServices` demonstrates.
135
135
136
136
<code-example header =" app-entity-services.ts " >
137
137
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 ';
144
139
145
140
import { SideKick } from '../../model';
146
141
import { HeroService, VillainService } from '../../services';
147
142
148
143
@Injectable ()
149
144
export class AppEntityServices extends EntityServicesBase {
150
145
constructor(
151
- public readonly store: Store< ; EntityCache> ; ,
152
- public readonly entityCollectionServiceFactory: EntityCollectionServiceFactory,
146
+ elements: EntityServicesElements,
153
147
154
148
// 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
157
151
) {
158
- super(store, entityCollectionServiceFactory );
152
+ super(elements );
159
153
this.registerEntityCollectionServices([ heroesService, villainsService] );
160
154
}
161
155
162
- // ... Additional convenience members
163
-
164
156
/** get the (default) SideKicks service * /
165
157
get sideKicksService() {
166
158
return this.getEntityCollectionService< ; SideKick> ; ('SideKick');
167
159
}
168
160
}
169
161
</code-example >
170
162
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.
173
168
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 .
175
170
The default service will do.
176
171
177
172
Nonetheless, we add a ` sideKicksService ` property that gets or creates a default service for ` SideKick ` .
0 commit comments