Forum Discussion

prem_iTalent's avatar
prem_iTalent
Community Manager
3 months ago

Atomic framework does not support Coveo JSUI-specific events.

Previously, Coveo's JSUI library provided the flexibility to customize the search behavior based on business requirements by using event handlers like buildingQuery, deferredQuerySuccess, doneBuildingQuery, and duringQuery.

Now Coveo has an updated Atomic framework, which is easier and more flexible to build the search interface, but at the same time, it's not providing the same features as JSUI to handle the events to customize the search behavior. Any suggestions or workarounds to achieve how we are using the deferredQuerySuccess to modify the field values before the search initialization.

  • vinay_iTalent's avatar
    vinay_iTalent
    Community Manager

    In the Coveo Atomic framework, while we may not have the same event handling methods available in JSUI, we do have alternative routes for managing requests and responses. Based on the following provided document, the PreProcessRequestMiddleware and preprocessSearchResponseMiddleware allow direct access to requests and responses, enabling manipulation as needed.

    The PreProcessRequestMiddleware is particularly valuable as it provides access to the request before the response is received and the page is loaded. This allows for various manipulations, such as modifying the request parameters or intercepting certain actions before they are executed.

    Conversely, the preprocessSearchResponseMiddleware operates after the page has loaded, providing access to the search response. Here, we can manipulate aspects such as the total count and other relevant data to suit our requirements.

    Furthermore, if there is a need to manipulate the results obtained from the response, we can access the response state directly.

    Coveo Reference Link, where it explain with the example and the code snippet: https://docs.coveo.com/en/atomic/latest/usage/atomic-modify-requests-responses/#modify-responses

    Hope this helps to resolve your use case.