Skip to content
This repository has been archived by the owner on Nov 27, 2019. It is now read-only.

Commit

Permalink
docs(router-store): Grammatical and consistency fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeHowellDev authored and brandonroberts committed Apr 26, 2018
1 parent 451cd37 commit 7cd10db
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 34 deletions.
28 changes: 15 additions & 13 deletions docs/router-store/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Bindings to connect the Angular Router with @ngrx/store

### Installation

Install @ngrx/router-store from npm:

`npm install @ngrx/router-store --save` OR `yarn add @ngrx/router-store`
Expand Down Expand Up @@ -33,11 +34,11 @@ export declare type RouterNavigationAction<T = RouterStateSnapshot> = {
};
```

- Reducers receive this action. Throwing an error in the reducer cancels navigation.
- Effects can listen for this action.
- The `ROUTER_CANCEL` action represents a guard canceling navigation.
- A `ROUTER_ERROR` action represents a navigation error .
- `ROUTER_CANCEL` and `ROUTER_ERROR` contain the store state before the navigation. Use the previous state to restore the consistency of the store.
* Reducers receive this action, throwing an error in the reducer cancels navigation.
* Effects can listen for this action.
* The `ROUTER_CANCEL` action represents a guard canceling navigation.
* A `ROUTER_ERROR` action represents a navigation error .
* `ROUTER_CANCEL` and `ROUTER_ERROR` contain the store state before the navigation. Use the previous state to restore the consistency of the store.

## Setup

Expand All @@ -49,21 +50,22 @@ import { AppComponent } from './app.component';
imports: [
BrowserModule,
StoreModule.forRoot({
router: routerReducer
router: routerReducer,
}),
RouterModule.forRoot([
// routes
]),
StoreRouterConnectingModule.forRoot({
stateKey: 'router' // name of reducer key
})
stateKey: 'router', // name of reducer key
}),
],
bootstrap: [AppComponent]
bootstrap: [AppComponent],
})
export class AppModule { }
export class AppModule {}
```

## API Documentation
- [Navigation actions](./api.md#navigation-actions)
- [Effects](./api.md#effects)
- [Custom Router State Serializer](./api.md#custom-router-state-serializer)

* [Navigation actions](./api.md#navigation-actions)
* [Effects](./api.md#effects)
* [Custom Router State Serializer](./api.md#custom-router-state-serializer)
40 changes: 19 additions & 21 deletions docs/router-store/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ export const FORWARD = '[Router] Forward';
export class Go implements Action {
readonly type = GO;

constructor(public payload: {
path: any[];
query?: object;
extras?: NavigationExtras;
}) {}
constructor(
public payload: {
path: any[];
query?: object;
extras?: NavigationExtras;
}
) {}
}

export class Back implements Action {
Expand All @@ -31,10 +33,7 @@ export class Forward implements Action {
readonly type = FORWARD;
}

export type RouterActionsUnion =
| Go
| Back
| Forward;
export type RouterActionsUnion = Go | Back | Forward;
```

```ts
Expand Down Expand Up @@ -67,9 +66,10 @@ export class RouterEffects {
navigate$ = this.actions$.pipe(
ofType(RouterActions.GO),
map((action: RouterActions.Go) => action.payload),
tap(({ path, query: queryParams, extras})
=> this.router.navigate(path, { queryParams, ...extras }))
)
tap(({ path, query: queryParams, extras }) =>
this.router.navigate(path, { queryParams, ...extras })
)
);

@Effect({ dispatch: false })
navigateBack$ = this.actions$.pipe(
Expand Down Expand Up @@ -98,7 +98,7 @@ issues when used with the Store Devtools. In most cases, you may only need a pie
Additionally, the router state snapshot is a mutable object, which can cause issues when developing with [store freeze](https://github.com/brandonroberts/ngrx-store-freeze) to prevent direct state mutations. This can be avoided by using a custom serializer.
**NOTE**: To use the time-traveling debugging in the Devtools with router-store, you must return an object containing a `url` property when using the `routerReducer`.
**NOTE**: To use the time-travelling debugging in the Devtools with router-store, you must return an object containing a `url` property when using the `routerReducer`.
```ts
import { StoreModule, ActionReducerMap } from '@ngrx/store';
Expand All @@ -107,7 +107,7 @@ import {
StoreRouterConnectingModule,
routerReducer,
RouterReducerState,
RouterStateSerializer
RouterStateSerializer,
} from '@ngrx/router-store';

export interface RouterStateUrl {
Expand Down Expand Up @@ -138,7 +138,7 @@ export class CustomSerializer implements RouterStateSerializer<RouterStateUrl> {
}

export const reducers: ActionReducerMap<State> = {
router: routerReducer
router: routerReducer,
};

@NgModule({
Expand All @@ -148,12 +148,10 @@ export const reducers: ActionReducerMap<State> = {
// routes
]),
StoreRouterConnectingModule.forRoot({
stateKey: 'router'
})
stateKey: 'router',
}),
],
providers: [
{ provide: RouterStateSerializer, useClass: CustomSerializer }
]
providers: [{ provide: RouterStateSerializer, useClass: CustomSerializer }],
})
export class AppModule { }
export class AppModule {}
```

0 comments on commit 7cd10db

Please sign in to comment.