algolia / vue-instantsearch

👀 Algolia components for building search UIs with Vue.js
https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/vue
MIT License
854 stars 157 forks source link

v2 - use cases for emitting events when refining #552

Closed Haroenv closed 1 year ago

Haroenv commented 5 years ago

Feedback on the v2 alpha version 🆕

Describe the bug / features

There might be some use cases where people want to listen to things happening inside widgets and do side effects. One major use case used to be routing, bu that can be solved in different ways now.

Reproduction

Please for every use case you have, make a sandbox link with https://codesandbox.io/s/zx4y4l9orl with the code you'd like to see working and give some explanation on what you expect to be emitted at which point

What is the version you are using?

Always try the latest one before opening an issue.

v2.0.0-alpha.3

drpeck commented 5 years ago

I've had to write a custom component, just to be able to output the number of page results in a location outside of the <ais-instant-search />

Haroenv commented 5 years ago

Thanks for that use case @drpeck. Which API would be ideal for you if it would exist?

drpeck commented 5 years ago

I guess just a change event on the main AIS component, for any changes to the state data changes. The full new state data provided as an argument, and potentially the old state data too if that wasn't too hard.


From: Haroen Viaene notifications@github.com Sent: Friday, February 8, 2019 3:46:02 PM To: algolia/vue-instantsearch Cc: David Peck; Mention Subject: Re: [algolia/vue-instantsearch] v2 - use cases for emitting events when refining (#552)

Thanks for that use case @drpeckhttps://github.com/drpeck. Which API would be ideal for you if it would exist?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/algolia/vue-instantsearch/issues/552#issuecomment-461845881, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ABJAD8sJs6p7UH_a-IFWAlFWX7jF5F1Bks5vLZu6gaJpZM4Xv6Wo.

haoyun commented 2 years ago

This was an old issue but i would also be happy to see if the ais-instantsearch compoent can emit the state changes.

Haroenv commented 2 years ago

What would you do with the event? There's middleware, onStateChange and widgets as well which could already cover your use case

haoyun commented 2 years ago

Thank you for replying! Actually later I found my use case a bit different from the current issue. I would like to use the refine method from the default slot of <ais-autocomplete /> outside that component, even outside <ais-instant-search />. Also I would like to use the state of <ais-instant-search > outside it. I found the method @drpeck provided inspiring, and that's how I was led to this issue. Later I found some other solution e.g., using template ref with onMounted(). I am sorry for disrupting the discussion with something irrelevant.

Haroenv commented 1 year ago

I'd say the low number of replies here indicates we don't need events