Skip to content

Instantly share code, notes, and snippets.

@vigohe
Created January 18, 2017 20:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vigohe/e07cabc69e2812a929bd9090cc223953 to your computer and use it in GitHub Desktop.
Save vigohe/e07cabc69e2812a929bd9090cc223953 to your computer and use it in GitHub Desktop.
import {Component, OnInit} from '@angular/core';
import { NavController } from 'ionic-angular';
import {BehaviorSubject, Observable} from "rxjs";
@Component({
selector: 'page-home',
template: `
<ion-header>
<ion-navbar>
<ion-title>Home</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
<ion-badge *ngFor="let tag of tags | async">{{tag.name}}</ion-badge>
</ion-content>
`
})
export class HomePage implements OnInit{
tags : BehaviorSubject<any> = new BehaviorSubject([]);
constructor(public navCtrl: NavController) {
}
ngOnInit(){
Observable.interval(2000)
.map(id => {
return { id: id, name: 'tag ' + id
};
})
.bufferWhen(() => Observable.interval(5000))
.subscribe(tags => this.tags.next(tags));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment