Created
January 19, 2017 17:38
-
-
Save vigohe/59bf347ee3762b6ad6d3b8ca8a9b6302 to your computer and use it in GitHub Desktop.
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
import {Component, OnInit, OnDestroy} from '@angular/core'; | |
import { NavController } from 'ionic-angular'; | |
import {Observable, Subject} from "rxjs"; | |
@Component({ | |
selector: 'page-home', | |
template: ` | |
<ion-header> | |
<ion-navbar> | |
<ion-title>Home</ion-title> | |
</ion-navbar> | |
</ion-header> | |
<ion-content padding> | |
<ion-card> | |
<ion-card-content> | |
<ion-card-title> | |
TEST | |
</ion-card-title> | |
<p> | |
User's UID is 1234 and the email is a@b.com | |
</p> | |
</ion-card-content> | |
<button *ngIf="hasFacebook" ion-button>Check in on FB</button> | |
<button *ngIf="!hasFacebook" ion-button>Link with FB</button> | |
<button ion-button>Logout</button> | |
</ion-card> | |
</ion-content> | |
` | |
}) | |
export class HomePage implements OnInit,OnDestroy{ | |
hasFacebook$: Subject<boolean> = new Subject<boolean>(); | |
destroy$ : Subject<any> = new Subject(); | |
hasFacebook: boolean = false; | |
constructor(public navCtrl: NavController){ | |
} | |
ngOnInit(){ | |
this | |
.hasFacebook$ | |
.takeUntil(this.destroy$) | |
.subscribe(hasFacebook => this.hasFacebook = hasFacebook); | |
Observable | |
.interval(3000) | |
.takeUntil(this.destroy$) | |
.subscribe(count => this.hasFacebook$.next((count % 2 === 0))); | |
} | |
ngOnDestroy(){ | |
this.destroy$.next(); | |
this.destroy$.unsubscribe(); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment