-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
AndreasAbdi
committed
Dec 7, 2016
1 parent
2fb829c
commit 1260609
Showing
8 changed files
with
98 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,31 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Launch Chrome against localhost, with sourcemaps", | ||
"type": "chrome", | ||
"request": "launch", | ||
"url": "http://localhost:3000", | ||
"sourceMaps": true, | ||
"webRoot": "${workspaceRoot}" | ||
}, | ||
{ | ||
"name": "Attach to Chrome, with sourcemaps", | ||
"type": "chrome", | ||
"request": "attach", | ||
"port": 9222, | ||
"sourceMaps": true, | ||
"webRoot": "${workspaceRoot}" | ||
} | ||
] | ||
} | ||
"version": "0.2.0", | ||
"configurations": [{ | ||
"name": "Launch Chrome against localhost, with sourcemaps", | ||
"type": "chrome", | ||
"request": "launch", | ||
"url": "http://localhost:4200/", | ||
"sourceMaps": true, | ||
"webRoot": "${workspaceRoot}", | ||
"sourceMapPathOverrides": { | ||
"webpack:///C:*": "C:/*" | ||
}, | ||
"runtimeArgs": [ | ||
"--disable-session-crashed-bubble", | ||
"--disable-infobars" | ||
], | ||
"diagnosticLogging": true | ||
}, { | ||
"name": "Attach to Chrome, with sourcemaps", | ||
"type": "chrome", | ||
"request": "attach", | ||
"port": 9222, | ||
"sourceMaps": true, | ||
/*"diagnosticLogging": true,*/ | ||
"webRoot": "${workspaceRoot}", | ||
"url": "http://localhost:4200/*", | ||
"sourceMapPathOverrides": { | ||
"webpack:///*": "/*" | ||
} | ||
}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"people": [{ | ||
"age": 40, | ||
"name": "Jordan Houston" | ||
}, { | ||
"age": 38, | ||
"name": "Robert Eastham" | ||
} ] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// import 'rxjs/Rx'; // adds ALL RxJS statics & operators to Observable | ||
|
||
// See node_module/rxjs/Rxjs.js | ||
// Import just the rxjs statics and operators needed for THIS app. | ||
|
||
// Statics | ||
import 'rxjs/add/observable/throw'; | ||
|
||
// Operators | ||
import 'rxjs/add/operator/catch'; | ||
import 'rxjs/add/operator/debounceTime'; | ||
import 'rxjs/add/operator/distinctUntilChanged'; | ||
import 'rxjs/add/operator/map'; | ||
import 'rxjs/add/operator/switchMap'; | ||
import 'rxjs/add/operator/toPromise'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,35 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { Http, Response } from '@angular/http'; | ||
|
||
import { Observable } from 'rxjs/Observable'; | ||
import '../shared/rxjs-operators'; | ||
|
||
@Injectable() | ||
export class SocketService { | ||
|
||
constructor() { } | ||
constructor(private http: Http) { } | ||
|
||
getData(): Observable<string> { | ||
return this.http.get('./assets/data.json') | ||
.map(this.extractData) | ||
.catch(this.handleError); | ||
} | ||
|
||
private extractData(response: Response) { | ||
const body = response.toString(); | ||
return body || {}; | ||
} | ||
|
||
private handleError(error: Response | any) { | ||
let errMsg: string; | ||
if (error instanceof Response) { | ||
const body = error.json() || ''; | ||
const err = body.error || JSON.stringify(body); | ||
errMsg = `${error.status} - ${error.statusText || ''} ${err}`; | ||
} else { | ||
errMsg = error.message ? error.message : error.toString(); | ||
} | ||
console.error(errMsg); | ||
return Observable.throw(errMsg); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,19 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { SocketService } from '../socket-service/socket.service'; | ||
|
||
@Component({ | ||
selector: 'websocket', | ||
templateUrl: './websocket.component.html' | ||
}) | ||
export class WebsocketComponent implements OnInit { | ||
datablock: string = 'sdfsdf'; | ||
constructor() { } | ||
constructor(private SocketService: SocketService) { } | ||
|
||
changeVal(): void { | ||
this.datablock = 'value has been changed'; | ||
this.SocketService.getData().subscribe( | ||
data => this.datablock = data, | ||
error => { }, | ||
); | ||
} | ||
ngOnInit() { } | ||
} |