-
Notifications
You must be signed in to change notification settings - Fork 386
Make it possible to refresh a InstantSearch instance #252
Comments
I agree we should do something about this use case. What would be the API of such a widget? How do you expect to use it? Same for the connector? What that would bring compare to a simple function? Can you clarify the concept of a "definitely search" button? |
for "definitely search", I had a use case in mind, where none of your filters are actually applied until you press a button to search (not exactly our ideal usecase), but now that I think about it again, that would need another concept. The widget would be rendering a button, on click, the results would refine. You could add that component yourself dynamically whenever you get a notice from your backend somehow that the data is stale. const App = () =>
<InstantSearch>
<SearchBox />
<Refresh />
<Hits />
<Pagination />
</InstantSearch>; This pattern is described in algolia/vue-instantsearch#241 (comment) The connector would look like this: const Refresh = connectRefresh(({ refine }) =>
<button onClick={() => refine()}> refresh </button>
); The refine function here will clear the cache, do a new query and update the results with that new query |
This would mean adding a side effect to call the clearCache inside the refine function (which the purpose is to return a new searchState based on the current one). I'm not a fan of the idea. Why not just having a regular |
How can you call that function then? (sorry, I feel out of the loop for a moment) |
Either with another HOC or indirectly by having
I thing it's good to explore options and compare each trade-off of them :) |
Could we provide an option to clear specified records? |
What exactly do you mean by that, @vinhlh; I have the feeling it might be an unrelated issue, feel free to open another issue for that. |
I mean, this issue is about adding an object to the index. What I did concern is similar: removing an object from the index. |
It will be more efficient to clear the cache than to store which objects are deleted; it will also not be simple to actually know which objects are deleted, so clearing the cache on a certain moment seems better to me. |
I did some research about this API request and here is what I propose:
@VincentCtr @georgejor @pyankoff @LaurentLousky @vinhlh @vvo @Haroenv: what do you think? |
I'm not 100% convinced, but with the |
LGTM 👍 |
Yeah that looks good to me as well!
…On Thu, Sep 7, 2017 at 4:11 PM Vincent Voyer ***@***.***> wrote:
LGTM 👍
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#252 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AEd9heXD40XCf5gt5WRsNi_NPLYSa7Gfks5sf-udgaJpZM4OzQCv>
.
|
I'm also craving for this feature. In the meanwhile, I helped me with this hack: clearCache() {
this.setState({
clearedCache: -(new Date()),
});
} ... <Configure filters={`createdAt > ${this.state.clearedCache}`} /> |
Thank you for sharing it @sokki, this feature is currently being worked on. Stay tuned! :) |
Do you want to request a feature or report a bug?
Feature
Feature: What is your use case for such a feature?
When you add an object to your index, you want the frontend to be updated. Right now this can be done slightly, by having a custom client, calling
.clearCache
and then somehow triggering a new search (mounting/unmounting or simulating an event in the input), but that's quite hacky.Feature: What is your proposed API entry? The new option to add? What is the behavior?
A widget and connector for
refresh
. It should callclient.clearCache()
, and search again with the current parameters.This can also be useful if you want a "definitely search" button.
related to #100, #131, algolia/vue-instantsearch#241 and this discourse post
The text was updated successfully, but these errors were encountered: