Skip to content

Commit

Permalink
refactor(data): rename NgRxDataModule to EntityDataModule (#1780)
Browse files Browse the repository at this point in the history
Closes #1777
  • Loading branch information
John Crowson authored and brandonroberts committed Apr 22, 2019
1 parent a53bffa commit 4c850b5
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
persistOps,
EntityAction,
EntityActionFactory,
NgrxDataModule,
EntityDataModule,
EntityCacheEffects,
EntityEffects,
EntityOp,
Expand Down Expand Up @@ -71,7 +71,7 @@ const entityMetadata = {

//////// Tests begin ////////

describe('NgrxDataModule', () => {
describe('EntityDataModule', () => {
describe('with replaced EntityEffects', () => {
// factory never changes in these tests
const entityActionFactory = new EntityActionFactory();
Expand All @@ -85,7 +85,7 @@ describe('NgrxDataModule', () => {
imports: [
StoreModule.forRoot({}),
EffectsModule.forRoot([]),
NgrxDataModule.forRoot({
EntityDataModule.forRoot({
entityMetadata: entityMetadata,
}),
],
Expand Down Expand Up @@ -152,7 +152,7 @@ describe('NgrxDataModule', () => {
imports: [
StoreModule.forRoot({}),
EffectsModule.forRoot([]),
NgrxDataModule.forRoot({
EntityDataModule.forRoot({
entityMetadata: entityMetadata,
entityCacheMetaReducers: [
loggingEntityCacheMetaReducer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
EntityCollection,
EntityOp,
EntityMetadataMap,
NgrxDataModule,
EntityDataModule,
EntityCacheEffects,
EntityDataService,
EntityDispatcherFactory,
Expand Down Expand Up @@ -471,7 +471,7 @@ function entityServicesSetup() {
imports: [
StoreModule.forRoot({}),
EffectsModule.forRoot([]),
NgrxDataModule.forRoot({
EntityDataModule.forRoot({
entityMetadata: entityMetadata,
}),
],
Expand Down
4 changes: 2 additions & 2 deletions modules/data/spec/entity-services/entity-services.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
EntityCacheQuerySet,
MergeQuerySet,
EntityMetadataMap,
NgrxDataModule,
EntityDataModule,
EntityCacheEffects,
EntityDataService,
EntityActionFactory,
Expand Down Expand Up @@ -202,7 +202,7 @@ function entityServicesSetup() {
imports: [
StoreModule.forRoot({}),
EffectsModule.forRoot([]),
NgrxDataModule.forRoot({
EntityDataModule.forRoot({
entityMetadata: entityMetadata,
}),
],
Expand Down
6 changes: 3 additions & 3 deletions modules/data/spec/selectors/related-entity-selectors.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
EntityActionFactory,
EntitySelectorsFactory,
EntityCache,
NgrxDataModuleWithoutEffects,
EntityDataModuleWithoutEffects,
ENTITY_METADATA_TOKEN,
EntityOp,
EntityAction,
Expand All @@ -41,9 +41,9 @@ describe('Related-entity Selectors', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [StoreModule.forRoot({}), NgrxDataModuleWithoutEffects],
imports: [StoreModule.forRoot({}), EntityDataModuleWithoutEffects],
providers: [
// required by NgrxData but not used in these tests
// required by EntityData but not used in these tests
{ provide: Actions, useValue: null },
{
provide: ENTITY_METADATA_TOKEN,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ import { EntityServicesBase } from './entity-services/entity-services-base';
import { EntityServicesElements } from './entity-services/entity-services-elements';
import { Logger, Pluralizer, PLURAL_NAMES_TOKEN } from './utils/interfaces';

export interface NgrxDataModuleConfig {
export interface EntityDataModuleConfig {
entityMetadata?: EntityMetadataMap;
entityCacheMetaReducers?: (
| MetaReducer<EntityCache, Action>
Expand Down Expand Up @@ -106,12 +106,12 @@ export interface NgrxDataModuleConfig {
{ provide: Logger, useClass: DefaultLogger },
],
})
export class NgrxDataModuleWithoutEffects implements OnDestroy {
export class EntityDataModuleWithoutEffects implements OnDestroy {
private entityCacheFeature: any;

static forRoot(config: NgrxDataModuleConfig): ModuleWithProviders {
static forRoot(config: EntityDataModuleConfig): ModuleWithProviders {
return {
ngModule: NgrxDataModuleWithoutEffects,
ngModule: EntityDataModuleWithoutEffects,
providers: [
{
provide: ENTITY_CACHE_META_REDUCERS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@ import { Pluralizer, PLURAL_NAMES_TOKEN } from './utils/interfaces';
import { DefaultPluralizer } from './utils/default-pluralizer';

import {
NgrxDataModuleConfig,
NgrxDataModuleWithoutEffects,
} from './ngrx-data-without-effects.module';
EntityDataModuleConfig,
EntityDataModuleWithoutEffects,
} from './entity-data-without-effects.module';

/**
* Ngrx-data main module includes effects and HTTP data services
* entity-data main module includes effects and HTTP data services
* Configure with `forRoot`.
* No `forFeature` yet.
*/
@NgModule({
imports: [
NgrxDataModuleWithoutEffects,
EntityDataModuleWithoutEffects,
EffectsModule, // do not supply effects because can't replace later
],
providers: [
Expand All @@ -57,12 +57,12 @@ import {
{ provide: Pluralizer, useClass: DefaultPluralizer },
],
})
export class NgrxDataModule {
static forRoot(config: NgrxDataModuleConfig): ModuleWithProviders {
export class EntityDataModule {
static forRoot(config: EntityDataModuleConfig): ModuleWithProviders {
return {
ngModule: NgrxDataModule,
ngModule: EntityDataModule,
providers: [
// TODO: Moved these effects classes up to NgrxDataModule itself
// TODO: Moved these effects classes up to EntityDataModule itself
// Remove this comment if that was a mistake.
// EntityCacheEffects,
// EntityEffects,
Expand Down Expand Up @@ -98,7 +98,7 @@ export class NgrxDataModule {
entityEffects: EntityEffects
) {
// We can't use `forFeature()` because, if we did, the developer could not
// replace the ngrx-data `EntityEffects` with a custom alternative.
// replace the entity-data `EntityEffects` with a custom alternative.
// Replacing that class is an extensibility point we need.
//
// The FEATURE_EFFECTS token is not exposed, so can't use that technique.
Expand Down
10 changes: 5 additions & 5 deletions modules/data/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ export * from './utils/guid-fns';
export * from './utils/interfaces';
export * from './utils/utilities';

// NgrxDataModule
export { NgrxDataModule } from './ngrx-data.module';
// EntityDataModule
export { EntityDataModule } from './entity-data.module';
export {
NgrxDataModuleWithoutEffects,
NgrxDataModuleConfig,
} from './ngrx-data-without-effects.module';
EntityDataModuleWithoutEffects,
EntityDataModuleConfig,
} from './entity-data-without-effects.module';
6 changes: 3 additions & 3 deletions projects/ngrx.io/content/guide/data/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,20 @@ Export the entity configuration to be used when registering it in your `AppModul

## Registering the entity store

Once the entity configuration is created, you need to put it into the root store for NgRx. This is done by importing the `entityConfig` and then passing it to the `NgrxDataModule.forRoot()` function.
Once the entity configuration is created, you need to put it into the root store for NgRx. This is done by importing the `entityConfig` and then passing it to the `EntityDataModule.forRoot()` function.

<code-example header="app.module.ts">
import { NgModule } from '@angular/core';
import { EffectsModule } from '@ngrx/effects';
import { StoreModule } from '@ngrx/store';
import { DefaultDataServiceConfig, NgrxDataModule } from '@ngrx/data';
import { DefaultDataServiceConfig, EntityDataModule } from '@ngrx/data';
import { entityConfig } from './entity-metadata';

@NgModule({
imports: [
StoreModule.forRoot({}),
EffectsModule.forRoot([]),
NgrxDataModule.forRoot(entityConfig)
EntityDataModule.forRoot(entityConfig)
]
})
export class AppModule {}
Expand Down

0 comments on commit 4c850b5

Please sign in to comment.