retrieving data from my service without waiting for it to complete.
This is the Component responsible for fetching data for my grid. The issue lies in this part: this.store.loadRequestHistory(this.id). When hovering over store, no data is displayed from items.
export class HistoryGridComponent implements OnInit {
id: number;
constructor(private route: ActivatedRoute,
private router: Router,
public store: HistoryStore) {
}
ngOnInit() {
this.route.paramMap
.map((params: ParamMap) => params.get('id'))
.subscribe(id => {
this.id = parseInt(id, 10);
let list = this.store.loadRequestHistory(this.id); // Data needed here
});
}
Below is the method from a service/store that successfully retrieves the data.
@action public async loadRequestHistory(requestId: number): Subscription {
this.loading = true;
let history = new HistoryClient(this.http, environment.apiUrl);
let response = history.getRequestHistory(requestId);
return response.subscribe(
(data) => {
try {
this.items = _(data)
.map(historySummaryMapper.map)
.value();
this.itemCount = data.length;
this.loading = false;
}
catch (error) {
console.log(error);
this.loading = false;
}
},
(error) => {
console.log(error);
this.loading = false;
},
() => {
this.loading = false;
}
);
}