Something has gone south in my code.
i have basically commented everything out of my component so that i looks like this now:
<div *ngFor="let restaurant of restaurants">
{{restaurant.updated}}
</div>
And after my http call to my api (which takes about 500ms) i do this:
this.restaurants = results;
Then it takes about 10+ seconds for it to rerender. I have a lot of warning in my console but i haven't managed to figure out why those are there.
as far as i know i dont have any "mousewheel" events in my app. And how can i figure out what "load" that took 3 seconds? And are these warnings acctually something that concerns my problem? Also the first time i do
this.restaurants = results;
It acts like it usually do and renders straight away.
Profiler result:
So after commenting everything out and taking one method at a time back i realizes this was the problem:
autocomplete.addListener("place_changed", () => {
const place = autocomplete.getPlace();
let foundCity = place.address_components.filter((address:any) => { if(address.types.some((type:any) => type == 'postal_town')){ return address} })[0].long_name;
if(foundCity){
this.userCity = foundCity;
let location = place.geometry.location;
this.userLongitude = location.lng();
this.userLatitude = location.lat();
This row inside of the event --> this.getRestaurants();
}
}, { passive: true });
It seems like when calling the getRestaurants() method which gets the restaurants from the db and then does:
this.restaurants = results;
Somehow blocks it from rendering.
When I do this:
<button type="button" class="btn btn-primary" (click)="getRestaurants()">Click</button>
It renders straight away. So how can i call getRestaurants() method after the place_changed event has happend?