I have a tag in HTML, which displays calendar:
<mwl-calendar-month-view
*ngSwitchCase="'month'"
[viewDate]="viewDate"
[events]="eventsValue"
>
"eventsValue" is a getter for CalendarEvent[] value. I get my calendar events via REST call. Then I subscribe to acquired observable. Inside "subscribe" I do some logic and create new CalendarEvent[] based on the response. Then I assign the newly created variable to he variable which is used in HTML file. What I'd expect is that when the value of variable used in HTML changes then the view is refreshed. But the effect is that calendar tries to be refreshed, but it happens in the moment when I call "subscribe" on my observable from REST call. Any ideas how can I have the updated value of events properly refreshed and have it visible in view? Function to call REST and update CalendarEvents[]:
public fetchCalendarData() {
const loggedUser = this.userService.getLoggedUser();
if (loggedUser) {
this.calendarService.fetchCalendarData(loggedUser).subscribe((response) => {
// some logic with response
this.eventsValue = [{
title: 'title',
start: new Date(),
end: new Date()
}];
});
}
}
Screenshot from debug to see when calendar view tries to refresh itself (I guess it's the moment when I get the warning about "events" being "undefined"):

Then after executing "subscribe" I called "this.events" in console I don't understand why it's still undefined (I just saw the value being updated in "subscribe").

eventsandeventsValueproperties? You are assigning toeventsValuebut reading fromevents? Also, is yourComponentdefined usingOnPushchange-detection orDefault? - Clemens Sum