@coveo/headless-react
    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.

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

    Hierarchy

    • Omit<CSRFacetGenerator, "state" | "facets">
      • FacetGenerator
    Index

    Methods

    • Deselects all values in all facets.

      Returns void

    • Adds a callback that's invoked on state change.

      Parameters

      • listener: () => void

        A callback that's invoked on state change.

      Returns Unsubscribe

      A function to remove the listener.

    Properties

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

    Builds a facet controller for the specified facet ID.

    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.