如何通过 API 从服务器获取数据调用生命周期挂钩并且不影响其他服务
How to call lifecycle hook with API getting data from a server and also not affect other services
//通过使用生命周期挂钩我正在获取数据,但另一种方法无法进行签名
ngDoCheck() {
this.FetchUsersInQueue(this.commonService.getUser());
}
onSignin() {
this.serverService.LoginMobileUser(this.modelSignIn).subscribe(data => { }, error => { });
}
thanks to all, I got the solution using constructor life cycle hook, refresh data list using Rxjs library
import 'rxjs/Rx';
import {
Observable
} from 'rxjs';
import {
map
} from 'rxjs/operators';
constructor() {
this.pollingData = Observable.interval(5000)
.switchMap(() => http.post('your http url', localVar)).map((data) => data.json())
.subscribe((data) => {
this.data = data;
});
}
//通过使用生命周期挂钩我正在获取数据,但另一种方法无法进行签名
ngDoCheck() {
this.FetchUsersInQueue(this.commonService.getUser());
}
onSignin() {
this.serverService.LoginMobileUser(this.modelSignIn).subscribe(data => { }, error => { });
}
thanks to all, I got the solution using constructor life cycle hook, refresh data list using Rxjs library
import 'rxjs/Rx';
import {
Observable
} from 'rxjs';
import {
map
} from 'rxjs/operators';
constructor() {
this.pollingData = Observable.interval(5000)
.switchMap(() => http.post('your http url', localVar)).map((data) => data.json())
.subscribe((data) => {
this.data = data;
});
}