algoliasearch-client-javascript icon indicating copy to clipboard operation
algoliasearch-client-javascript copied to clipboard

Allow users to add custom methods to a client

Open Haroenv opened this issue 5 years ago • 0 comments

I want to be able to add a custom method, at instantiation of algoliasearch, but without monkeypatching.

algoliasearch('xxx','yyy', {
  methods: { initPlaces }
})

Right now this isn't possible with the "bundled" algoliasearch, but it is possible if you are doing createSearchClient manually, since ...options is followed by methods overridden, without it being spread inside.

The methods I'm adding should probably override the existing methods, so you can do a conditional search more easy for example.

This should also be autocompleted by TypeScript (which likely won't be an issue as soon as we add the methods key to ClientSearchOptions)

Haroenv avatar Jul 10 '20 15:07 Haroenv