The ais-hits view event

The documentation for hits says:

The view event is automatically sent when this connector renders hits.

I want to be able to call a method when ais-hits returns results. But how do you do that on ais-hits?

On ais-pagination for example, I can do @page-change="myMethod". I thought maybe it would be @view but that’s not it.

Could you achieve a similar effect by monitoring state to see when the query returns results?

You could use the same pattern as the “loading” indiator:

I probably need to provide more of my code because I’m already using ais-stats which seems to do a similar thing.

<div :class="{ searchResults: isResults }">
    <ais-stats v-slot="{ nbHits }">
        <ais-hits
            v-if="nbHits"
            v-slot="{ items }"
            @view="resultsExist" // I thought this could call a method that will then set isResults to true
        >
            <Product v-for="item in items" :key="item.objectID" :product="item" />
        </ais-hits>

        <p v-else>No results.</p>
    </ais-stats>

    <ais-pagination></ais-pagination>
</div>    

I want to be able to apply a class to the wrapping div of ais-stats depending on whether results are showing or not.