Skip to content

update to official package versions #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Simple Ng2-Redux with SystemJS Config
# Simple @angular-redux/store example with SystemJS config

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

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

# How to Run It

Expand Down
6 changes: 3 additions & 3 deletions app/actions.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Injectable } from '@angular/core';
import { NgRedux } from 'ng2-redux';
import { NgRedux } from '@angular-redux/store';
import { AppState } from './store';

@Injectable()
export class CounterActions {
static INCREMENT = "INCREMENT";
static DECREMENT = "DECREMENT";
static INCREMENT = 'INCREMENT';
static DECREMENT = 'DECREMENT';

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

Expand Down
16 changes: 11 additions & 5 deletions app/app.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { NgRedux, DevToolsExtension } from '@angular-redux/store';
import { StoreCreator } from 'redux';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/of';
import { NgRedux } from 'ng2-redux';

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

// I follow a 'mock all dependencies' strategy when unit testing.
const mockNgRedux = {
configureStore: () => {},
dispatch: () => {},
select: () => Observable.of(null),
};
NgRedux.instance = mockNgRedux;

const mockDevToolsExtension = {
isEnabled: () => false,
enhancer: (): StoreCreator => null,
};

const mockCounterActions = {
increment: () => {},
decrement: () => {},
Expand All @@ -31,6 +36,7 @@ describe('AppComponent', function () {
declarations: [ AppComponent ],
providers: [
{ provide: NgRedux, useValue: mockNgRedux },
{ provide: DevToolsExtension, useValue: mockDevToolsExtension },
{ provide: CounterActions, useValue: mockCounterActions },
],
})
Expand All @@ -48,7 +54,7 @@ describe('AppComponent', function () {
it('should have expected <h1> text', () => {
fixture.detectChanges();
const h1 = de.nativeElement;
expect(h1.innerText).toMatch(/NG2-Redux/i,
expect(h1.innerText).toMatch(/@angular-redux\/store/i,
'<h1> should say something about "Redux"');
});
});
15 changes: 10 additions & 5 deletions app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component } from '@angular/core';
import { NgRedux, select } from 'ng2-redux';
import { NgRedux, select, DevToolsExtension } from '@angular-redux/store';
import { Observable } from 'rxjs/Observable';

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

constructor(
private ngRedux: NgRedux<any>,
ngRedux: NgRedux<AppState>,
devTools: DevToolsExtension,
private actions: CounterActions) {
ngRedux.configureStore(rootReducer, INITIAL_STATE);
ngRedux.configureStore(
rootReducer,
INITIAL_STATE,
null,
devTools.isEnabled() ? [ devTools.enhancer() ] : []);
}
}
2 changes: 1 addition & 1 deletion app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { NgReduxModule } from 'ng2-redux';
import { NgReduxModule } from '@angular-redux/store';

import { AppComponent } from './app.component';
import { CounterActions } from './actions';
Expand Down
6 changes: 3 additions & 3 deletions app/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ export interface AppState {
}

export const INITIAL_STATE: AppState = {
counter: 0
}
counter: 0,
};

export function rootReducer(state: AppState, action: Action): AppState {
switch(action.type) {
switch (action.type) {
case CounterActions.INCREMENT: return { counter: state.counter + 1 };
case CounterActions.DECREMENT: return { counter: state.counter - 1 };
default: return state;
Expand Down
2 changes: 1 addition & 1 deletion e2e/app.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { browser, element, by } from 'protractor';

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

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

beforeEach(function () {
browser.get('');
Expand Down
4 changes: 2 additions & 2 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ module.exports = function(config) {
{ pattern: 'node_modules/rxjs/**/*.js.map', included: false, watched: false },

// Redux
{ pattern: 'node_modules/ng2-redux/**/*.js', included: false, watched: false },
{ pattern: 'node_modules/ng2-redux/**/*.js.map', included: false, watched: false },
{ pattern: 'node_modules/@angular-redux/store/**/*.js', included: false, watched: false },
{ pattern: 'node_modules/@angular-redux/store/**/*.js.map', included: false, watched: false },
{ pattern: 'node_modules/redux/**/*.js', included: false, watched: false },
{ pattern: 'node_modules/redux/**/*.js.map', included: false, watched: false },

Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"author": "",
"license": "MIT",
"dependencies": {
"@angular-redux/store": "^6.0.0",
"@angular/common": "~2.4.0",
"@angular/compiler": "~2.4.0",
"@angular/core": "~2.4.0",
Expand All @@ -27,31 +28,30 @@
"@angular/router": "~3.4.0",
"angular-in-memory-web-api": "~0.2.2",
"core-js": "^2.4.1",
"ng2-redux": "^5.1.0",
"redux": "^3.6.0",
"reflect-metadata": "^0.1.8",
"rxjs": "5.0.1",
"systemjs": "0.19.40",
"zone.js": "^0.7.4"
},
"devDependencies": {
"concurrently": "^3.1.0",
"lite-server": "^2.2.2",
"typescript": "~2.0.10",
"@types/jasmine": "^2.5.36",
"@types/node": "^6.0.46",
"canonical-path": "0.0.2",
"concurrently": "^3.1.0",
"http-server": "^0.9.0",
"tslint": "^3.15.1",
"lodash": "^4.16.4",
"jasmine-core": "~2.4.1",
"karma": "^1.3.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-jasmine-html-reporter": "^0.2.2",
"lite-server": "^2.2.2",
"lodash": "^4.16.4",
"protractor": "~4.0.14",
"rimraf": "^2.5.4",
"@types/node": "^6.0.46",
"@types/jasmine": "^2.5.36"
"tslint": "^3.15.1",
"typescript": "~2.0.10"
},
"repository": {}
}
4 changes: 2 additions & 2 deletions systemjs.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
// other libraries
'rxjs': 'npm:rxjs',
'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
'ng2-redux': 'npm:ng2-redux',
'@angular-redux/store': 'npm:@angular-redux/store',
'redux': 'npm:redux',
},
// packages tells the System loader how to load when no filename and/or no extension
Expand All @@ -38,7 +38,7 @@
rxjs: {
defaultExtension: 'js'
},
'ng2-redux': { main: 'lib/index.js', defaultExtension: 'js' },
'@angular-redux/store': { main: 'lib/index.js', defaultExtension: 'js' },
redux: { main: 'dist/redux.min.js', defaultExtension: 'js' },
}
});
Expand Down
Loading