# Class Initialization

The main purpose of this class is to initialize the framework (a.k.a the code executed when calling `Coveo.init`).
It's also in charge or registering the available components, as well as the method that we expost to the global Coveo scope.
For example, the `Coveo.executeQuery` function will be registed in this class by the QueryController.

## Index

### Methods

- automaticallyCreateComponentsInside
- automaticallyCreateComponentsInsideResult
- getListOfLoadedComponents
- getListOfRegisteredComponents
- getRegisteredComponent
- getRegisteredFieldsComponentForQuery
- getRegisteredFieldsForQuery
- initRecommendationInterface
- initSearchInterface
- initStandaloneSearchInterface
- initializeFramework
- isComponentClassIdRegistered
- isNamedMethodRegistered
- monkeyPatchComponentMethod
- registerAutoCreateComponent
- registerComponentFields
- registerDefaultOptions
- registerNamedMethod

## Methods

### Static automaticallyCreateComponentsInside

- automaticallyCreateComponentsInside(element: HTMLElement, initParameters: IInitializationParameters, ignore?: string[]): IInitResult

- - Defined in ui/Base/Initialization.ts :434

  Scan the element and all its children for known components. Initialize every known component found.

  #### Parameters

  - ##### element: HTMLElement

  - ##### initParameters: IInitializationParameters

  - ##### Default value ignore: string[] = []

  #### Returns IInitResult

### Static automaticallyCreateComponentsInsideResult

- automaticallyCreateComponentsInsideResult(resultElement: HTMLElement, result: IQueryResult, optionsToInject?: object): IInitResult

- - Defined in ui/Base/Initialization.ts :411

  Scan the result element and all its children for known components. Initialize every known result component found.

  See also : Initialization.automaticallyCreateComponentsInside.

  #### Parameters

  - ##### resultElement: HTMLElement

    The root element to scan for known components

  - ##### result: IQueryResult

    The result which needs to be passed to each result component constructor.

  - ##### Default value optionsToInject: object = {}

    A set of options to inject for the components found inside the resultElement. These options will be merged with any options passed during the "init" call of the search interface.

  #### Returns IInitResult

### Static getListOfLoadedComponents

- getListOfLoadedComponents(): string[]

- - Defined in ui/Base/Initialization.ts :213

  Return the list of all components that are currently eagerly loaded.

  #### Returns string[]

### Static getListOfRegisteredComponents

- getListOfRegisteredComponents(): String[]

- - Defined in ui/Base/Initialization.ts :205

  Return the list of all known components (the list of ID for each component), whether they are actually loaded or not.

  #### Returns String[]

### Static getRegisteredComponent

- getRegisteredComponent(name: string): IComponentDefinition

- - Defined in ui/Base/Initialization.ts :225

  Return the component class definition, using it's ID (e.g. : 'CoveoFacet').

  This means the component needs to be eagerly loaded.

  #### Parameters

  - ##### name: string

  #### Returns IComponentDefinition

### Static getRegisteredFieldsComponentForQuery

- getRegisteredFieldsComponentForQuery(componentId: string): string[]

- - Defined in ui/Base/Initialization.ts :183

  Returns all the fields that the framework currently knows should be added to the query, for a given component.

  This is used when the is set to `true` (which is `true` by default).

  The framework tries to only include the needed fields from the index, for performance reasons.

  #### Parameters

  - ##### componentId: string

  #### Returns string[]

### Static getRegisteredFieldsForQuery

- getRegisteredFieldsForQuery(): string[]

- - Defined in ui/Base/Initialization.ts :170

  Returns all the fields that the framework currently knows should be added to the query.

  This is used when the is set to `true` (which is `true` by default).

  The framework tries to only include the needed fields from the index, for performance reasons.

  #### Returns string[]

### Static initRecommendationInterface

- initRecommendationInterface(element: HTMLElement, options?: any): IInitResult

- - Defined in ui/Base/Initialization.ts :388

  Create a new recommendation search interface. This is the function executed when calling `Coveo.initRecommendation`.

  #### Parameters

  - ##### element: HTMLElement

  - ##### Default value options: any = {}

  #### Returns IInitResult

### Static initSearchInterface

- initSearchInterface(element: HTMLElement, options?: any): IInitResult

- - Defined in ui/Base/Initialization.ts :342

  Create a new standard search interface. This is the function executed when calling `Coveo.init`.

  #### Parameters

  - ##### element: HTMLElement

  - ##### Default value options: any = {}

  #### Returns IInitResult

### Static initStandaloneSearchInterface

- initStandaloneSearchInterface(element: HTMLElement, options?: any): IInitResult

- - Defined in ui/Base/Initialization.ts :356

  Create a new standalone search interface (standalone search box). This is the function executed when calling `Coveo.initSearchbox`.

  #### Parameters

  - ##### element: HTMLElement

  - ##### Default value options: any = {}

  #### Returns IInitResult

### Static initializeFramework

- initializeFramework(element: HTMLElement, options: any, initSearchInterfaceFunction: function): Promise<object>

- - Defined in ui/Base/Initialization.ts :236

  Initialize the framework. Note that this function should not normally be called directly, but instead using a globally registered function (e.g.: Coveo.init), or Initialization.initSearchInterface or Initialization.initStandaloneSearchInterface
  (e.g. : `Coveo.init` or `Coveo.initSearchbox`).

  #### Parameters

  - ##### element: HTMLElement

    The element on which to initialize the interface.

  - ##### options: any

    The options for all components (eg: {Searchbox : {enableSearchAsYouType : true}}).

  - ##### initSearchInterfaceFunction: function

    The function to execute to create the SearchInterface component. Different init call will create different SearchInterface.

    - - (...args: any[]): IInitResult

      - #### Parameters

        - ##### Rest ...args: any[]

        #### Returns IInitResult

  #### Returns Promise<object>

### Static isComponentClassIdRegistered

- isComponentClassIdRegistered(componentClassId: string): boolean

- - Defined in ui/Base/Initialization.ts :194

  Check if a component is already registered, using it's ID (e.g. : 'Facet').

  #### Parameters

  - ##### componentClassId: string

  #### Returns boolean

### Static isNamedMethodRegistered

- isNamedMethodRegistered(methodName: string): boolean

- - Defined in ui/Base/Initialization.ts :500

  Check if the method is already registed.

  #### Parameters

  - ##### methodName: string

  #### Returns boolean

### Static monkeyPatchComponentMethod

- monkeyPatchComponentMethod(methodName: string, element: HTMLElement, handler: function): void

- - Defined in ui/Base/Initialization.ts :510

  'Monkey patch' (replace the function with a new one) a given method on a component instance.

  #### Parameters

  - ##### methodName: string

  - ##### element: HTMLElement

  - ##### handler: function

    - - (...args: any[]): any

      - #### Parameters

        - ##### Rest ...args: any[]

        #### Returns any

  #### Returns void

### Static registerAutoCreateComponent

- registerAutoCreateComponent(componentClass: IComponentDefinition): void

- - Defined in ui/Base/Initialization.ts :107

  Register a new Component to be recognized by the framework. This essentially mean that when we call `Coveo.init`, the Initialization class will scan the DOM for known component (which have registed themselves with this call) and create a new component on each element.

  This is meant to register the component to be loaded "eagerly" (Immediately available when the UI scripts are included)

  #### Parameters

  - ##### componentClass: IComponentDefinition

  #### Returns void

### Static registerComponentFields

- registerComponentFields(componentId: string, fields: string[]): void

- - Defined in ui/Base/Initialization.ts :142

  Set the fields that the component needs to add to the query.

  This is used when the is set to `true` (which is `true` by default).

  The framework tries to only include the needed fields from the index, for performance reasons.

  #### Parameters

  - ##### componentId: string

    The id for the result template component (see Result Templates).

  - ##### fields: string[]

  #### Returns void

### Static registerDefaultOptions

- registerDefaultOptions(element: HTMLElement, options: __type): void

- - Defined in ui/Base/Initialization.ts :77

  Register a new set of options for a given element.
  When the element is eventually initialized as a component, those options will be used / merged to create the final option set to use for this component.
  Note that this function should not normally be called directly, but instead using the global `Coveo.options` function

  #### Parameters

  - ##### element: HTMLElement

  - ##### options: __type

  #### Returns void

### Static registerNamedMethod

- registerNamedMethod(methodName: string, handler: function): void

- - Defined in ui/Base/Initialization.ts :487

  Register a new globally available method in the Coveo namespace (e.g.: `Coveo.init`).

  #### Parameters

  - ##### methodName: string

    The method name to register.

  - ##### handler: function

    The function to execute when the method is called.

    - - (...args: any[]): any

      - #### Parameters

        - ##### Rest ...args: any[]

        #### Returns any

  #### Returns void

### Hierarchy

- Initialization