forked from pragyandas/WeatherApp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
weather.ts
30 lines (28 loc) · 1021 Bytes
/
weather.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
var Firebase = require("firebase");
import * as Rx from '@reactivex/rxjs';
export interface IWeather{
weatherDataSubject:Rx.Subject<any>,
weatherDetailSubject:Rx.Subject<any>,
weatherForcastSubject:Rx.Subject<any>,
getWeatherDetails:(string)=>void
}
export class Weather implements IWeather{
constructor(){
this.firebase = new Firebase('https://publicdata-weather.firebaseio.com');
this.firebase.on("value", (result) => {
this.weatherDataSubject.next(result.val());
});
}
firebase:any;
weatherDataSubject:Rx.Subject<any>=new Rx.Subject<any>();
weatherDetailSubject:Rx.Subject<any>=new Rx.Subject<any>();
weatherForcastSubject:Rx.Subject<any>=new Rx.Subject<any>();
getWeatherDetails=(city: string) : void =>{
this.firebase.child('/'+city+'/currently').on("value",(result)=>{
this.weatherDetailSubject.next(result.val());
});
this.firebase.child('/'+city+'/daily/data').on("value",(result)=>{
this.weatherForcastSubject.next(result.val());
});
}
}