@coveo/headless
    Preparing search index...

    Interface FacetGenerator

    The FacetGenerator headless sub-controller creates commerce facet sub-controllers from the Commerce API search or product listing response.

    Commerce facets are not requested by the implementer, but rather pre-configured through the Coveo Merchandising Hub (CMH). The implementer is only responsible for leveraging the facet controllers created by this sub-controller to properly render facets in their application.

    See Implement server-side rendering.

    interface FacetGenerator {
        getFacetController: <T extends FacetType>(
            facetId: string,
            facetType: T,
        ) => undefined | MappedGeneratedFacetController[T];
        state: MappedFacetStates;
        deselectAll(): void;
        subscribe(listener: () => void): Unsubscribe;
    }

    Hierarchy

    Index

    Methods

    Properties

    getFacetController: <T extends FacetType>(
        facetId: string,
        facetType: T,
    ) => undefined | MappedGeneratedFacetController[T]

    Builds a facet controller for the specified facet ID.

    See Implement server-side rendering.

    Type declaration

      • <T extends FacetType>(
            facetId: string,
            facetType: T,
        ): undefined | MappedGeneratedFacetController[T]
      • Type Parameters

        Parameters

        • facetId: string

          The unique identifier of the facet.

        • facetType: T

          The type of facet to build.

        Returns undefined | MappedGeneratedFacetController[T]

        A facet controller of the specified type, or undefined if the facet does not exist in the state.

    The state of each every facet returned by the Commerce API.

    In a server-side rendering (SSR) scenario, use this state to render the facet UI components before the facet controller is hydrated on the client side.

    Once the facet generator controller has been hydrated, use the getFacetController method to retrieve the individual facet controllers and subscribe to their respective states.

    See Implement server-side rendering.