Skip to content

Commit cfb5c17

Browse files
Merge pull request #1 from angular-redux/chore/rename-v6-publish
update to official package versions
2 parents 20483c0 + f276f7d commit cfb5c17

File tree

11 files changed

+193
-163
lines changed

11 files changed

+193
-163
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
# Simple Ng2-Redux with SystemJS Config
1+
# Simple @angular-redux/store example with SystemJS config
22

33
This repo was cloned from the Angular2 quickstart example:
44
https://angular.io/docs/ts/latest/guide/setup.html
55

66
It's a trivial counter built with
7-
[Ng2-Redux](https://npmjs.org/packages/ng2-redux); it's main purpose is to show
8-
how to set up Ng2-Redux in a SystemJS/TypeScript/LiveServer environment.
7+
[@angular-redux/store](https://npmjs.org/packages/@angular-redux/store); it's
8+
main purpose is to show how to set up @angular-redux/store in a
9+
SystemJS/TypeScript/LiveServer environment.
910

1011
# How to Run It
1112

app/actions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { Injectable } from '@angular/core';
2-
import { NgRedux } from 'ng2-redux';
2+
import { NgRedux } from '@angular-redux/store';
33
import { AppState } from './store';
44

55
@Injectable()
66
export class CounterActions {
7-
static INCREMENT = "INCREMENT";
8-
static DECREMENT = "DECREMENT";
7+
static INCREMENT = 'INCREMENT';
8+
static DECREMENT = 'DECREMENT';
99

1010
constructor(private ngRedux: NgRedux<AppState>) {}
1111

app/app.component.spec.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2-
import { By } from '@angular/platform-browser';
2+
import { By } from '@angular/platform-browser';
33
import { DebugElement } from '@angular/core';
4-
import { Observable } from 'rxjs/Observable';
4+
import { NgRedux, DevToolsExtension } from '@angular-redux/store';
5+
import { StoreCreator } from 'redux';
6+
import { Observable } from 'rxjs/Observable';
57
import 'rxjs/add/observable/of';
6-
import { NgRedux } from 'ng2-redux';
78

89
import { AppComponent } from './app.component';
910
import { CounterActions } from './actions';
1011

11-
// I follow a 'mock all dependencies' strategy when unit testing.
1212
const mockNgRedux = {
1313
configureStore: () => {},
1414
dispatch: () => {},
1515
select: () => Observable.of(null),
1616
};
1717
NgRedux.instance = mockNgRedux;
1818

19+
const mockDevToolsExtension = {
20+
isEnabled: () => false,
21+
enhancer: (): StoreCreator => null,
22+
};
23+
1924
const mockCounterActions = {
2025
increment: () => {},
2126
decrement: () => {},
@@ -31,6 +36,7 @@ describe('AppComponent', function () {
3136
declarations: [ AppComponent ],
3237
providers: [
3338
{ provide: NgRedux, useValue: mockNgRedux },
39+
{ provide: DevToolsExtension, useValue: mockDevToolsExtension },
3440
{ provide: CounterActions, useValue: mockCounterActions },
3541
],
3642
})
@@ -48,7 +54,7 @@ describe('AppComponent', function () {
4854
it('should have expected <h1> text', () => {
4955
fixture.detectChanges();
5056
const h1 = de.nativeElement;
51-
expect(h1.innerText).toMatch(/NG2-Redux/i,
57+
expect(h1.innerText).toMatch(/@angular-redux\/store/i,
5258
'<h1> should say something about "Redux"');
5359
});
5460
});

app/app.component.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Component } from '@angular/core';
2-
import { NgRedux, select } from 'ng2-redux';
2+
import { NgRedux, select, DevToolsExtension } from '@angular-redux/store';
33
import { Observable } from 'rxjs/Observable';
44

55
import { CounterActions } from './actions';
@@ -8,7 +8,7 @@ import { AppState, INITIAL_STATE, rootReducer } from './store';
88
@Component({
99
selector: 'my-app',
1010
template: `
11-
<h1>Hello NG2-Redux!</h1>
11+
<h1>Hello @angular-redux/store!</h1>
1212
<p>The counter value is {{ counter$ | async }}</p>
1313
<p>
1414
<button (click)="actions.increment()">+</button>
@@ -17,11 +17,16 @@ import { AppState, INITIAL_STATE, rootReducer } from './store';
1717
`
1818
})
1919
export class AppComponent {
20-
@select() counter$: Observable<number>;
20+
@select() readonly counter$: Observable<number>;
2121

2222
constructor(
23-
private ngRedux: NgRedux<any>,
23+
ngRedux: NgRedux<AppState>,
24+
devTools: DevToolsExtension,
2425
private actions: CounterActions) {
25-
ngRedux.configureStore(rootReducer, INITIAL_STATE);
26+
ngRedux.configureStore(
27+
rootReducer,
28+
INITIAL_STATE,
29+
null,
30+
devTools.isEnabled() ? [ devTools.enhancer() ] : []);
2631
}
2732
}

app/app.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { NgModule } from '@angular/core';
22
import { BrowserModule } from '@angular/platform-browser';
3-
import { NgReduxModule } from 'ng2-redux';
3+
import { NgReduxModule } from '@angular-redux/store';
44

55
import { AppComponent } from './app.component';
66
import { CounterActions } from './actions';

app/store.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ export interface AppState {
66
}
77

88
export const INITIAL_STATE: AppState = {
9-
counter: 0
10-
}
9+
counter: 0,
10+
};
1111

1212
export function rootReducer(state: AppState, action: Action): AppState {
13-
switch(action.type) {
13+
switch (action.type) {
1414
case CounterActions.INCREMENT: return { counter: state.counter + 1 };
1515
case CounterActions.DECREMENT: return { counter: state.counter - 1 };
1616
default: return state;

e2e/app.e2e-spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { browser, element, by } from 'protractor';
22

33
describe('QuickStart E2E Tests', function () {
44

5-
let expectedMsg = 'Hello NG2-Redux!';
5+
let expectedMsg = 'Hello @angular-redux/store!';
66

77
beforeEach(function () {
88
browser.get('');

karma.conf.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ module.exports = function(config) {
5454
{ pattern: 'node_modules/rxjs/**/*.js.map', included: false, watched: false },
5555

5656
// Redux
57-
{ pattern: 'node_modules/ng2-redux/**/*.js', included: false, watched: false },
58-
{ pattern: 'node_modules/ng2-redux/**/*.js.map', included: false, watched: false },
57+
{ pattern: 'node_modules/@angular-redux/store/**/*.js', included: false, watched: false },
58+
{ pattern: 'node_modules/@angular-redux/store/**/*.js.map', included: false, watched: false },
5959
{ pattern: 'node_modules/redux/**/*.js', included: false, watched: false },
6060
{ pattern: 'node_modules/redux/**/*.js.map', included: false, watched: false },
6161

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"author": "",
1818
"license": "MIT",
1919
"dependencies": {
20+
"@angular-redux/store": "^6.0.0",
2021
"@angular/common": "~2.4.0",
2122
"@angular/compiler": "~2.4.0",
2223
"@angular/core": "~2.4.0",
@@ -27,31 +28,30 @@
2728
"@angular/router": "~3.4.0",
2829
"angular-in-memory-web-api": "~0.2.2",
2930
"core-js": "^2.4.1",
30-
"ng2-redux": "^5.1.0",
3131
"redux": "^3.6.0",
3232
"reflect-metadata": "^0.1.8",
3333
"rxjs": "5.0.1",
3434
"systemjs": "0.19.40",
3535
"zone.js": "^0.7.4"
3636
},
3737
"devDependencies": {
38-
"concurrently": "^3.1.0",
39-
"lite-server": "^2.2.2",
40-
"typescript": "~2.0.10",
38+
"@types/jasmine": "^2.5.36",
39+
"@types/node": "^6.0.46",
4140
"canonical-path": "0.0.2",
41+
"concurrently": "^3.1.0",
4242
"http-server": "^0.9.0",
43-
"tslint": "^3.15.1",
44-
"lodash": "^4.16.4",
4543
"jasmine-core": "~2.4.1",
4644
"karma": "^1.3.0",
4745
"karma-chrome-launcher": "^2.0.0",
4846
"karma-cli": "^1.0.1",
4947
"karma-jasmine": "^1.0.2",
5048
"karma-jasmine-html-reporter": "^0.2.2",
49+
"lite-server": "^2.2.2",
50+
"lodash": "^4.16.4",
5151
"protractor": "~4.0.14",
5252
"rimraf": "^2.5.4",
53-
"@types/node": "^6.0.46",
54-
"@types/jasmine": "^2.5.36"
53+
"tslint": "^3.15.1",
54+
"typescript": "~2.0.10"
5555
},
5656
"repository": {}
5757
}

systemjs.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
// other libraries
2727
'rxjs': 'npm:rxjs',
2828
'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
29-
'ng2-redux': 'npm:ng2-redux',
29+
'@angular-redux/store': 'npm:@angular-redux/store',
3030
'redux': 'npm:redux',
3131
},
3232
// packages tells the System loader how to load when no filename and/or no extension
@@ -38,7 +38,7 @@
3838
rxjs: {
3939
defaultExtension: 'js'
4040
},
41-
'ng2-redux': { main: 'lib/index.js', defaultExtension: 'js' },
41+
'@angular-redux/store': { main: 'lib/index.js', defaultExtension: 'js' },
4242
redux: { main: 'dist/redux.min.js', defaultExtension: 'js' },
4343
}
4444
});

0 commit comments

Comments
 (0)