algoliasearch-client-javascript
algoliasearch-client-javascript copied to clipboard
Allow users to add custom methods to a client
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)