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

Commit

Permalink
docs(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 9c0c60e commit db6421c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 41 deletions.
8 changes: 4 additions & 4 deletions docs/store/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ RxJS powered state management for Angular applications, inspired by Redux
@ngrx/store is a controlled state container designed to help write performant, consistent applications
on top of Angular. Core tenets:

* State is a single immutable data structure
* Actions describe state changes
* Pure functions called reducers take the previous state and the next action to compute the new state
* State accessed with the `Store`, an observable of state and an observer of actions
* State is a single, immutable data structure.
* Actions describe state changes.
* Pure functions called reducers take the previous state and the next action to compute the new state.
* State accessed with the `Store`, an observable of state and an observer of actions.

These core principles enable building components that can use the `OnPush` change detection strategy
giving you [intelligent, performant change detection](http://blog.thoughtram.io/angular/2016/02/22/angular-2-change-detection-explained.html#smarter-change-detection)
Expand Down
64 changes: 29 additions & 35 deletions docs/store/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Initial State

Configure initial state when providing Store. `initialState` can be either the actual state, or a function that returns the initial state:
Configure initial state when providing Store. `initialState` can be either the actual state or a function that returns the initial state:

```ts
import { StoreModule } from '@ngrx/store';
Expand All @@ -12,10 +12,10 @@ import { reducers } from './reducers';
imports: [
StoreModule.forRoot(reducers, {
initialState: {
counter: 3
}
})
]
counter: 3,
},
}),
],
})
export class AppModule {}
```
Expand Down Expand Up @@ -59,15 +59,13 @@ export function debug(reducer: ActionReducer<any>): ActionReducer<any> {
console.log('action', action);

return reducer(state, action);
}
};
}

export const metaReducers: MetaReducer<any>[] = [debug];

@NgModule({
imports: [
StoreModule.forRoot(reducers, { metaReducers })
]
imports: [StoreModule.forRoot(reducers, { metaReducers })],
})
export class AppModule {}
```
Expand All @@ -89,9 +87,7 @@ export const reducers: ActionReducerMap<any> = {
};

@NgModule({
imports: [
StoreModule.forFeature('featureName', reducers)
]
imports: [StoreModule.forFeature('featureName', reducers)],
})
export class FeatureModule {}
```
Expand All @@ -100,7 +96,7 @@ The feature state is added to the global application state once the feature is l

## Injecting Reducers

To inject the root reducers into your application, use an `InjectionToken` and a `Provider` to register the reducers through dependency injection.
To inject the root reducers into your application, use an `InjectionToken` and a `Provider` to register the reducers through dependency injection.

```ts
import { NgModule, InjectionToken } from '@angular/core';
Expand All @@ -109,25 +105,25 @@ import { StoreModule, ActionReducerMap } from '@ngrx/store';
import { SomeService } from './some.service';
import * as fromRoot from './reducers';

export const REDUCER_TOKEN = new InjectionToken<ActionReducerMap<fromRoot.State>>('Registered Reducers');
export const REDUCER_TOKEN = new InjectionToken<
ActionReducerMap<fromRoot.State>
>('Registered Reducers');

export function getReducers(someService: SomeService) {
return someService.getReducers();
}

@NgModule({
imports: [
StoreModule.forRoot(REDUCER_TOKEN),
],
imports: [StoreModule.forRoot(REDUCER_TOKEN)],
providers: [
{
provide: REDUCER_TOKEN,
deps: [SomeService],
useFactory: getReducers
}
]
useFactory: getReducers,
},
],
})
export class AppModule { }
export class AppModule {}
```

Reducers are also injected when composing state through feature modules.
Expand All @@ -138,27 +134,25 @@ import { StoreModule, ActionReducerMap } from '@ngrx/store';

import * as fromFeature from './reducers';

export const FEATURE_REDUCER_TOKEN = new InjectionToken<ActionReducerMap<fromFeature.State>>('Feature Reducers');
export const FEATURE_REDUCER_TOKEN = new InjectionToken<
ActionReducerMap<fromFeature.State>
>('Feature Reducers');

export function getReducers(): ActionReducerMap<fromFeature.State> {
// map of reducers
return {

};
return {};
}

@NgModule({
imports: [
StoreModule.forFeature('feature', FEATURE_REDUCER_TOKEN),
],
imports: [StoreModule.forFeature('feature', FEATURE_REDUCER_TOKEN)],
providers: [
{
provide: FEATURE_REDUCER_TOKEN,
useFactory: getReducers
}
]
useFactory: getReducers,
},
],
})
export class FeatureModule { }
export class FeatureModule {}
```

## Injecting Meta-Reducers
Expand All @@ -180,9 +174,9 @@ export function getMetaReducers(some: SomeService): MetaReducer[] {
{
provide: META_REDUCERS,
deps: [SomeService],
useFactory: getMetaReducers
}
]
useFactory: getMetaReducers,
},
],
})
export class AppModule {}
```
4 changes: 2 additions & 2 deletions docs/store/selectors.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ For example, imagine you have a `selectedUser` object in the state. You also hav

And you want to show all books for the current user.

You can use the `createSelector` to achieve just that. Your visible books will always be up to date even if you update them in `allBooks` and they will always show the books that belong to your user if there is one selected, and will show all the books when there is no user selected.
You can use `createSelector` to achieve just that. Your visible books will always be up to date even if you update them in `allBooks`. They will always show the books that belong to your user if there is one selected and will show all the books when there is no user selected.

The result will be just some of your state filtered by another section of the state. And it will be always up to date.

Expand Down Expand Up @@ -106,7 +106,7 @@ export const selectFeatureCount = createSelector(

## Reset Memoized Selector

The selector function returned by calling `createSelector` or `createFeatureSelector` initially has a memoized value of `null`. After a selector is invoked the first time its memoized value is stored in memory. If the selector is subsequently invoked with the same arguments it will return the memoized value. If the selector is then invoked with different arguments it will recompute, and update its memoized value. Consider the following:
The selector function returned by calling `createSelector` or `createFeatureSelector` initially has a memoized value of `null`. After a selector is invoked the first time its memoized value is stored in memory. If the selector is subsequently invoked with the same arguments it will return the memoized value. If the selector is then invoked with different arguments it will recompute and update its memoized value. Consider the following:

```ts
import { createSelector } from '@ngrx/store';
Expand Down

0 comments on commit db6421c

Please sign in to comment.