Last active
June 14, 2017 21:12
-
-
Save michaelchadwick/844283521567734284f9935250533d92 to your computer and use it in GitHub Desktop.
angular 2 testing - HomeComponent
This file contains hidden or 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
import { Component, OnInit, OnDestroy } from '@angular/core'; | |
import { Response } from '@angular/http'; | |
import { Subscription } from 'rxjs/Subscription'; | |
import { DaveService } from '../_services/dave.service'; | |
import { devlog } from '../_helpers/devlog'; | |
@Component({ | |
moduleId: module.id, | |
templateUrl: './home.component.html', | |
styleUrls: [ './home.component.css' ] | |
}) | |
export class HomeComponent implements OnInit, OnDestroy { | |
private dave: any; | |
private daveSub: Subscription; | |
constructor( | |
private daveService:DaveService, | |
) { } | |
ngOnInit() { | |
this.daveCheckSubscribeObservable(); | |
} | |
ngOnDestroy() { | |
this.daveSub.unsubscribe(); | |
} | |
private daveCheckSubscribeObservable() { | |
this.daveSub = this.daveService.daveCheckObservable().subscribe( | |
(daveData: any) => console.log('this.dave post-Obs-call', daveData), | |
(error) => console.log(error), | |
() => console.log('daveCheckObservable Completed!') | |
); | |
} | |
private daveCheckObservable() { | |
devlog('api', 'calling daveService.daveCheckObservable()') | |
this.dave = this.daveService.daveCheckObservable(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment