Home > widget-integration > FilterController > connect

FilterController.connect() method

Connects and initializes the filter controller with the provided configuration. This is the primary entry point for setting up the filter system.

Sets up the filter state with configuration and initializes all core functionality including event listeners, UI components, and filter tree rendering.

Signature:

connect(config: Record<string, unknown>): Promise<void>;

Parameters

Parameter

Type

Description

config

Record<string, unknown>

Configuration object containing: - document: HTMLElement - The DOM context for the filter - blockType: string - Type of block ('filter') - widgetId: string - Widget identifier - defaultParams: object - Default filter parameters - filter: object - Initial filter tree data

Returns:

Promise<void>

Example 1

Basic usage:

await filterController.connect({
  document: document.getElementById('boost-sd-filter'),
  blockType: 'filter',
  widgetId: 'filter-widget-123',
  defaultParams: { page: 1, limit: 24 },
  filter: filterTreeData
});

Example 2

Extended implementation:

window.boostWidgetIntegration.extend('FilterController', (FilterController) => {
  return class CustomFilterController extends FilterController {
    async connect(config) {
      // Add custom initialization logic
      this.initCustomAnalytics();
      await super.connect(config);
    }
  };
});