Skip to content

Commit

Permalink
docs(Store): edit README and use Angular code style in examples (#1114)
Browse files Browse the repository at this point in the history
  • Loading branch information
oboukli authored and brandonroberts committed Jun 22, 2018
1 parent 55a0488 commit 6cf99f1
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions docs/store/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ change detection strategy giving you
[intelligent, performant change detection](https://blog.thoughtram.io/angular/2016/02/22/angular-2-change-detection-explained.html#smarter-change-detection)
throughout your application.

### Installation
## Installation

Install @ngrx/store from npm:

`npm install @ngrx/store --save` OR `yarn add @ngrx/store`
`npm install @ngrx/store` or `yarn add @ngrx/store`

### Nightly builds

`npm install github:ngrx/store-builds` OR `yarn add github:ngrx/store-builds`
`npm install github:ngrx/store-builds` or `yarn add github:ngrx/store-builds`

### Setup
## Setup

Create a reducer function for each data type you have in your application. The
combination of these reducers will make up your application state:
Expand All @@ -40,7 +40,9 @@ export const INCREMENT = 'INCREMENT';
export const DECREMENT = 'DECREMENT';
export const RESET = 'RESET';

export function counterReducer(state: number = 0, action: Action) {
const initialState = 0;

export function counterReducer(state: number = initialState, action: Action) {
switch (action.type) {
case INCREMENT:
return state + 1;
Expand All @@ -67,7 +69,7 @@ import { StoreModule } from '@ngrx/store';
import { counterReducer } from './counter';

@NgModule({
imports: [BrowserModule, StoreModule.forRoot({ count: counterReducer })],
imports: [StoreModule.forRoot({ count: counterReducer })],
})
export class AppModule {}
```
Expand All @@ -76,6 +78,7 @@ You can then inject the `Store` service into your components and services. Use
`select` operator to _select_ slice(s) of state:

```ts
import { Component } from '@angular/core';
import { Store, select } from '@ngrx/store';
import { Observable } from 'rxjs';
import { INCREMENT, DECREMENT, RESET } from './counter';
Expand All @@ -85,7 +88,7 @@ interface AppState {
}

@Component({
selector: 'my-app',
selector: 'app-my-counter',
template: `
<button (click)="increment()">Increment</button>
<div>Current Count: {{ count$ | async }}</div>
Expand All @@ -94,7 +97,7 @@ interface AppState {
<button (click)="reset()">Reset Counter</button>
`,
})
export class MyAppComponent {
export class MyCounterComponent {
count$: Observable<number>;

constructor(private store: Store<AppState>) {
Expand Down Expand Up @@ -128,10 +131,10 @@ export class MyAppComponent {
* [Typed Actions](./actions.md#typed-actions)
* [Use Store service with AngularJS](./downgrade.md)

### Additional Material
## Additional Material

* [From Inactive to Reactive with ngrx](https://www.youtube.com/watch?v=cyaAhXHhxgk)
* [From Inactive to Reactive with ngrx (video)](https://www.youtube.com/watch?v=cyaAhXHhxgk)
* [Reactive Angular 2 with ngrx (video)](https://youtu.be/mhA7zZ23Odw)
* [Comprehensive Introduction to @ngrx/store](https://gist.github.com/btroncone/a6e4347326749f938510)
* [@ngrx/store in 10 minutes (video)](https://egghead.io/lessons/angular-2-ngrx-store-in-10-minutes)
* [Build Redux Style Applications with Angular, RxJS, and @ngrx/store (video)](https://egghead.io/courses/building-a-time-machine-with-angular-2-and-rxjs)
* [@ngrx/store in 10 minutes (course)](https://egghead.io/lessons/angular-2-ngrx-store-in-10-minutes)
* [Build Redux Style Applications with Angular, RxJS, and @ngrx/store (course)](https://egghead.io/courses/building-a-time-machine-with-angular-2-and-rxjs)

0 comments on commit 6cf99f1

Please sign in to comment.