From 122d03376f5bb6514aca2deadd151b4408e864a3 Mon Sep 17 00:00:00 2001 From: Ward Bell Date: Tue, 9 Oct 2018 22:31:19 -0400 Subject: [PATCH] 6.1.0-beta.0 --- README.md | 12 +++++++---- docs/entity-metadata.md | 11 ++++++---- lib/CHANGELOG.md | 6 ++++++ lib/package.json | 2 +- src/app/store/entity/entity-metadata.ts | 28 +++++++++++++------------ 5 files changed, 37 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index f1923f7a..0bde9b5e 100644 --- a/README.md +++ b/README.md @@ -41,12 +41,16 @@ You can make your own calls to the server and update the cached entity collectio You can see the _ngrx machinery_ at work with the [_redux developer tools_](#redux-dev-tools). You can listen to the flow of actions directly. You can _intercept and override anything_ ... but you only have to intervene where you want to add custom logic. -### Show me +### Learn about it -For a hands-on experience, try the [QuickStart](https://github.com/johnpapa/ngrx-data-lab/blob/master/README.md). -In this section, we summarize the key points. +For a hands-on experience, try the [QuickStart](https://github.com/johnpapa/ngrx-data-lab/blob/master/README.md) +in the tutorial git repo, **[ngrx-data-lab](https://github.com/johnpapa/ngrx-data-lab/)**, +which guides you on the few, simple steps necessary to migrate from a typical service-based Angular app, to an app that manages state with _ngrx-data_. + +_This_ **ngrx-data repository** has the main documentation and its own sample app. + +The sample app in the `src/client/app/` folder presents an editor for viewing and changing _Heroes_ and _Villains_. -The _ngrx-data_ repository includes a demo app for editing _Heroes_ and _Villains_ in the `src/client/app/` folder. The following _reduced_ extract from that demo illustrates the essential mechanics of configuring and using _ngrx-data_. You begin with a description of the entity model in a few lines of metadata. diff --git a/docs/entity-metadata.md b/docs/entity-metadata.md index 8f210678..03ba96aa 100644 --- a/docs/entity-metadata.md +++ b/docs/entity-metadata.md @@ -236,14 +236,17 @@ The `HttpUrlGenerator` can't pluralize the entity type name on its own. It deleg The `Pluralizer` class has a _pluralize()_ method that takes the singular string and returns the plural string. -The default `Pluralizer` handles many of the common English pluralization rules such as appending an `'s'`. That's fine for the `Villain` type (which becomes "villains"). -That's the wrong technique for pluralizing the `Hero` type (which becomes "heros"). +The default `Pluralizer` handles many of the common English pluralization rules such as appending an `'s'`. +That's fine for the `Villain` type (which becomes "Villains") and even for `Company` (which becomes "Companies"). + +It's far from perfect. For example, it incorrectly turns `Hero` into "Heros" instead of "Heroes". Fortunately, the default `Pluralizer` also injects a map of singular to plural strings (with the `PLURAL_NAMES_TOKEN`). -Its `pluralize()` method looks for the singular entity name in that map and uses the corresponding plural value if found. Otherwise, it returns the entity name plus `'s'`. +Its `pluralize()` method looks for the singular entity name in that map and uses the corresponding plural value if found. +Otherwise, it returns the default pluralization of the entity name. -If this scheme works for you, create a map of _singular-to-plural_ entity names for the exceptional cases, as the demo app does: +If this scheme works for you, create a map of _singular-to-plural_ entity names for the exceptional cases: ```javascript export const pluralNames = { diff --git a/lib/CHANGELOG.md b/lib/CHANGELOG.md index 9287c290..4cdfeb95 100644 --- a/lib/CHANGELOG.md +++ b/lib/CHANGELOG.md @@ -24,6 +24,12 @@ as this will keep you from installing `6.1.x`.
+# 6.1.0-beta.0 (2018-10-09) + +Advance to Beta. No changes. The new APIs are working well in a production application and there are no reported issues with them. + + + # 6.1.0-alpha.4 (2018-10-01) Fix: missing `@Optional()` on `EntityCacheDataService` constructor parameter diff --git a/lib/package.json b/lib/package.json index 18501f8d..d4c1197b 100644 --- a/lib/package.json +++ b/lib/package.json @@ -1,6 +1,6 @@ { "name": "ngrx-data", - "version": "6.1.0-alpha.4", + "version": "6.1.0-beta.0", "repository": "https://github.com/johnpapa/angular-ngrx-data.git", "license": "MIT", "peerDependencies": { diff --git a/src/app/store/entity/entity-metadata.ts b/src/app/store/entity/entity-metadata.ts index a17dc1fa..3c8155db 100644 --- a/src/app/store/entity/entity-metadata.ts +++ b/src/app/store/entity/entity-metadata.ts @@ -1,8 +1,4 @@ -import { - defaultSelectId, - EntityMetadataMap, - PropsFilterFnFactory -} from 'ngrx-data'; +import { defaultSelectId, EntityMetadataMap, PropsFilterFnFactory } from 'ngrx-data'; export const entityMetadata: EntityMetadataMap = { Hero: { @@ -24,20 +20,26 @@ export const entityMetadata: EntityMetadataMap = { } }; +// Special pluralization mapping for words the defaultPluralizer can't pluralize +// The plural of "Hero" is not "Heros"; it's "Heroes" +// Important: Case matters. Match the case of the entity name. export const pluralNames = { - // Not needed for data access when set Hero's HttpResourceUrls; see `entity-store.module.ts`. - // Case matters. Match the case of the entity name. Hero: 'Heroes' }; -// Can't just put the function in the entityMetadata literal -// AOT obliges us to encapsulate the logic in wrapper functions +// ---------------- +// In _this particular example_, this pluralNames mapping is not actually needed +// because the example set the Hero's `HttpResourceUrls` directly rather than relying on pluralization; +// see `entity-store.module.ts`. +// ---------------- + +// FILTERS AND SORTERS + +// Can't embed these functions directly in the entityMetadata literal because +// AOT requires us to encapsulate the logic in wrapper functions /** Filter for entities whose name matches the case-insensitive pattern */ -export function nameFilter( - entities: T[], - pattern: string -) { +export function nameFilter(entities: T[], pattern: string) { return PropsFilterFnFactory(['name'])(entities, pattern); }