@forcecalendar/interface 1.0.21 → 1.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forcecalendar/interface",
3
- "version": "1.0.21",
3
+ "version": "1.0.22",
4
4
  "type": "module",
5
5
  "description": "Official interface layer for forceCalendar Core - Enterprise calendar components",
6
6
  "main": "dist/force-calendar-interface.umd.js",
@@ -31,6 +31,7 @@ export class ForceCalendar extends BaseComponent {
31
31
  this.currentView = null;
32
32
  this._hasRendered = false; // Track if initial render is complete
33
33
  this._cachedStyles = null; // Cache styles to avoid recreation
34
+ this._busUnsubscribers = [];
34
35
  }
35
36
 
36
37
  initialize() {
@@ -53,25 +54,29 @@ export class ForceCalendar extends BaseComponent {
53
54
  }
54
55
 
55
56
  setupEventListeners() {
57
+ // Clean up any existing subscriptions before re-subscribing
58
+ this._busUnsubscribers.forEach(unsub => unsub());
59
+ this._busUnsubscribers = [];
60
+
56
61
  // Navigation events
57
- eventBus.on('navigation:*', (data, event) => {
62
+ this._busUnsubscribers.push(eventBus.on('navigation:*', (data, event) => {
58
63
  this.emit('calendar-navigate', { action: event.split(':')[1], ...data });
59
- });
64
+ }));
60
65
 
61
66
  // View change events
62
- eventBus.on('view:changed', (data) => {
67
+ this._busUnsubscribers.push(eventBus.on('view:changed', (data) => {
63
68
  this.emit('calendar-view-change', data);
64
- });
69
+ }));
65
70
 
66
71
  // Event management events
67
- eventBus.on('event:*', (data, event) => {
72
+ this._busUnsubscribers.push(eventBus.on('event:*', (data, event) => {
68
73
  this.emit(`calendar-event-${event.split(':')[1]}`, data);
69
- });
74
+ }));
70
75
 
71
76
  // Date selection events
72
- eventBus.on('date:selected', (data) => {
77
+ this._busUnsubscribers.push(eventBus.on('date:selected', (data) => {
73
78
  this.emit('calendar-date-select', data);
74
- });
79
+ }));
75
80
  }
76
81
 
77
82
  handleStateChange(newState, oldState) {
@@ -857,10 +862,12 @@ export class ForceCalendar extends BaseComponent {
857
862
  }
858
863
 
859
864
  destroy() {
865
+ this._busUnsubscribers.forEach(unsub => unsub());
866
+ this._busUnsubscribers = [];
867
+
860
868
  if (this.stateManager) {
861
869
  this.stateManager.destroy();
862
870
  }
863
- eventBus.clear();
864
871
  super.cleanup();
865
872
  }
866
873
  }
@@ -868,4 +875,4 @@ export class ForceCalendar extends BaseComponent {
868
875
  // Register component
869
876
  if (!customElements.get('forcecal-main')) {
870
877
  customElements.define('forcecal-main', ForceCalendar);
871
- }
878
+ }