-
Notifications
You must be signed in to change notification settings - Fork 157
feat(search-client): Add support for Custom Search Clients #432
Conversation
src/components/Index.vue
Outdated
); | ||
} | ||
|
||
this._localSearchStore = createFromAlgoliaClient(Object.create(this.searchClient)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Object.create()
is not necessary here. I will remove it.
src/components/Index.vue
Outdated
} else { | ||
this._localSearchStore = this.searchStore; | ||
if (!this.searchStore) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be changed to else if
I think :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, ESLint is never happy with that ahah.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me
const client = this._helper.getClient(); | ||
|
||
if (typeof client.addAlgoliaAgent === 'function') { | ||
client.addAlgoliaAgent(`vue-instantsearch ${version}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we could add this conditionally in the helper so we can call it without checking here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm OK with this change. It's yet another helper upgrade though haha. WDYT @bobylito?
I wonder if this deserves a mention in the search store guide |
@Haroenv I've never really used Vue InstantSearch so you decide what's better for the users! How would you see that? We could add another section below "Create a search store from an Algolia client instance" like "Create a search store from a custom client instance". We'll have to document both |
A section there seems good! |
This PR adds support for the
search-client
prop. This allows any InstantSearch user to plug their own search client (including a custom Algolia backend).Usage
Demo
(see file
src/App.vue
)Related feature in InstantSearch.js