Skip to content

Commit

Permalink
docs: update for the new store structure
Browse files Browse the repository at this point in the history
  • Loading branch information
dhhyi committed Jun 15, 2020
1 parent 0fe99e4 commit 2d9cafa
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
21 changes: 17 additions & 4 deletions docs/concepts/state-management.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ src/app/core
| └─ index.ts
├─ bar
| └─ ...
├─ foobar.state.ts
└─ foobar.system.ts
├─ foobar-store.ts
└─ foobar-store.module.ts
```

An application module named `foobar` with substates named `foo` and `bar` serves as an example.
Expand All @@ -93,12 +93,25 @@ Each substate should aggregate its store components in separate subfolders corre

Furthermore, the state of foobar is aggregated in two files:

- _foobar.state.ts_: Contains the `FoobarState` as an aggregate of the `foo` and `bar` states.
- _foobar-store.ts_: Contains the `FoobarState` as an aggregate of the `foo` and `bar` states.

- _foobar.system.ts_: Contains aggregations for `foobarReducers` and `foobarEffects` of the corresponding substates to be used in modules and `TestBed` declarations.
- _foobar-store.module.ts_: Contains aggregations for `foobarReducers` and `foobarEffects` of the corresponding substates as well as the store module.

Access to the state slice of `foobar` is provided with the `FoobarFacade` located in _foobar.facade.ts_

## Core Store Structure

The PWA has a core state initializing the [StoreModule.forRoot](https://ngrx.io/api/store/StoreModule#forroot) and multiple feature modules using [StoreModule.forFeature](https://ngrx.io/api/store/StoreModule#forfeature).

- `core`: PWA runtime independent of the ICM like configuration, global error handling or [@ngrx/router-store](https://ngrx.io/guide/router-store) integration.
- `shopping`: Logic and data for browsing the PWA independent of the current user.
- `customer`: Everything user-related (anonymous or logged in) like the current basket or the user profile.
- `content`: Everything related to the CMS.
- `general`: Minor features that don't require a fully fledged feature store.
- ...

All store modules are aggregated and imported in the [`StateManagementModule`](../../src/app/core/state-management.module.ts).

## Naming

Related to the example in the previous paragraph, we want to establish a particular naming scheme.
Expand Down
21 changes: 21 additions & 0 deletions docs/guides/migrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,27 @@ The old testing mechanism will be removed in version 0.23.

We introduced a way to do [shallow testing with feature toggles](../concepts/configuration.md#unit-testing-with-feature-toggles) and used it in the tests.

We [reorganized the core store](../concepts/state-management.md#core-store-structure):

- new `customer`
- store/addresses => store/**customer**/addresses
- store/checkout/basket => store/**customer**/basket
- store/orders => store/**customer**/orders
- store/restore => store/**customer**/restore
- store/user => store/**customer**/user
- new `core`
- store/configuration => store/**core**/configuration
- store/error => store/**core**/error
- store/messages => store/**core**/messages
- store/router => store/**core**/router
- store/viewconf => store/**core**/viewconf
- new `general`
- store/contact => store/**general**/contact
- store/countries => store/**general**/countries
- store/regions => store/**general**/regions

TSLint rules are set up to automatically fix imports, so run `npm run check` after upgrading.

## 0.19.1 to 0.20

We upgraded from Angular 8 to version 9 and activated the new rendering engine Ivy with this (following the [official upgrade guide](https://update.angular.io/#8.0:9.0l3)).
Expand Down

0 comments on commit 2d9cafa

Please sign in to comment.