Skip to content

Commit

Permalink
feat(connector): complete jsdoc + pass instantsearch to view
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandre Stanislawski committed Mar 24, 2017
1 parent 2486f36 commit e125931
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/connectors/search-box/connectSearchBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var customSearchBox = connectMenu(function render(params, isFirstRendering) {
// query,
// onHistoryChange,
// search,
// instantSearchInstance
// }
});
search.addWidget(
Expand All @@ -25,9 +26,10 @@ Full documentation available at https://community.algolia.com/instantsearch.js/c

/**
* @typedef {Object} SearchBoxRenderingOptions
* @property {string} query
* @property {function} onHistoryChange
* @property {function} search
* @property {string} query the query from the last search
* @property {function} onHistoryChange set a callback when the browser history changes
* @property {function} search triggers the search with a `query` as parameter
* @property {InstantSearch} instantSearchInstance the instance of instantsearch on which the widget is attached
*/

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

return ({queryHook}) => ({
init({helper, onHistoryChange}) {
init({helper, onHistoryChange, instantSearchInstance}) {
this._search = (() => {
let previousQuery;

Expand All @@ -62,14 +64,16 @@ export default function connectSearchBox(renderFn) {
query: helper.state.query,
onHistoryChange: this._onHistoryChange,
search: this._search,
instantSearchInstance,
}, true);
},

render({helper}) {
render({helper, instantSearchInstance}) {
renderFn({
query: helper.state.query,
onHistoryChange: this._onHistoryChange,
search: this._search,
instantSearchInstance,
}, false);
},
});
Expand Down

0 comments on commit e125931

Please sign in to comment.