Skip to content

Commit e125931

Browse files
author
Alexandre Stanislawski
committed
feat(connector): complete jsdoc + pass instantsearch to view
1 parent 2486f36 commit e125931

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/connectors/search-box/connectSearchBox.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ var customSearchBox = connectMenu(function render(params, isFirstRendering) {
66
// query,
77
// onHistoryChange,
88
// search,
9+
// instantSearchInstance
910
// }
1011
});
1112
search.addWidget(
@@ -25,9 +26,10 @@ Full documentation available at https://community.algolia.com/instantsearch.js/c
2526

2627
/**
2728
* @typedef {Object} SearchBoxRenderingOptions
28-
* @property {string} query
29-
* @property {function} onHistoryChange
30-
* @property {function} search
29+
* @property {string} query the query from the last search
30+
* @property {function} onHistoryChange set a callback when the browser history changes
31+
* @property {function} search triggers the search with a `query` as parameter
32+
* @property {InstantSearch} instantSearchInstance the instance of instantsearch on which the widget is attached
3133
*/
3234

3335
/**
@@ -39,7 +41,7 @@ export default function connectSearchBox(renderFn) {
3941
checkRendering(renderFn, usage);
4042

4143
return ({queryHook}) => ({
42-
init({helper, onHistoryChange}) {
44+
init({helper, onHistoryChange, instantSearchInstance}) {
4345
this._search = (() => {
4446
let previousQuery;
4547

@@ -62,14 +64,16 @@ export default function connectSearchBox(renderFn) {
6264
query: helper.state.query,
6365
onHistoryChange: this._onHistoryChange,
6466
search: this._search,
67+
instantSearchInstance,
6568
}, true);
6669
},
6770

68-
render({helper}) {
71+
render({helper, instantSearchInstance}) {
6972
renderFn({
7073
query: helper.state.query,
7174
onHistoryChange: this._onHistoryChange,
7275
search: this._search,
76+
instantSearchInstance,
7377
}, false);
7478
},
7579
});

0 commit comments

Comments
 (0)