Home > widget-integration > FilterStore > notifyWatchers

FilterStore.notifyWatchers() method

Notifies all registered watchers of state changes.

This method is called automatically after setState(). Override this method to customize notification behavior, such as debouncing notifications or filtering which watchers to notify based on shop-specific logic.

Signature:

protected notifyWatchers(): void;

Returns:

void

Remarks

This method iterates through all watchers and calls their callbacks with either the entire state or specific property values depending on how they were registered.

Example

Debounce notifications for better performance:

protected notifyWatchers() {
  clearTimeout(this.notifyTimeout);
  this.notifyTimeout = setTimeout(() => {
    super.notifyWatchers();
  }, 100);
}