mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 11:17:19 +08:00
34 lines
698 B
JavaScript
34 lines
698 B
JavaScript
import {Promise} from 'angular2/src/facade/async';
|
|
console.log(Promise);
|
|
|
|
var APIUrl = 'https://hacker-news.firebaseio.com/v0';
|
|
export class HackerNewsClient {
|
|
constructor() {
|
|
this.fb = new Firebase(APIUrl);
|
|
}
|
|
|
|
getTopStories(cb) {
|
|
console.log('GETTING TOP STORIES');
|
|
|
|
this.fb.child('topstories').on('value', (snapshot) => {
|
|
|
|
let items = snapshot.val();
|
|
|
|
console.log('Fetched', items.length, 'items');
|
|
|
|
for(var itemID of items) {
|
|
|
|
this.fb.child("item").child(itemID).on('value', (data) => {
|
|
|
|
cb(data.val());
|
|
|
|
//console.log(data.val());
|
|
});
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
var HackerNews = new HackerNewsClient();
|
|
export { HackerNews };
|