mattlewis92 / angular-calendar

A flexible calendar component for angular 15.0+ that can display events on a month, week or day view.
https://mattlewis92.github.io/angular-calendar/
MIT License
2.72k stars 864 forks source link

Add meta properties changes detection in the refresh process #1597

Open titaii2 opened 2 years ago

titaii2 commented 2 years ago

Is your feature request related to a problem? Please describe

The calendar doesn't refresh when changing some meta properties after calling this.refresh.next().

Describe the solution you'd like

Trigger the function refreshBody of calendar when at least 1 meta property has changed.

Describe your use case for implementing this feature

I'm using a CustomEventTitleFormatter to add an image directly for each event I create. I pass the image URL in the meta properties and when the URL changes (and by triggering this.refresh.next()), I would like the calendar being updated too. My case only concern body because I'm only using CustomEventTitleFormatter.

Additional context

I think changes detection is happening here so change.events should includes meta properties changes too. image

matts-bot[bot] commented 2 years ago

Thanks so much for opening an issue! If you'd like me to give priority to answering your issue or would just like to support this project, then please consider sponsoring me

titaii2 commented 2 years ago

@mattlewis92 ?

mattlewis92 commented 2 years ago

I think your issue here is that you're not creating a new reference to the events array when updating the meta object. Angular doesn't deep check objects for differences for performance reasons and adding that to the calendar would seriously affect performance when you have a large number of events. Doing something as simple as:

this.events = [...this.events];

When you update the meta properties should be enough to create a new reference and trigger change detection. Let me know if that works for you!