Skip to content

Commit

Permalink
feat(connectors): connectToggle, forward initial options to render
Browse files Browse the repository at this point in the history
  • Loading branch information
iam4x committed Mar 24, 2017
1 parent 52d13de commit 704a455
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/connectors/toggle/connectToggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Full documentation available at https://community.algolia.com/instantsearch.js/c
* @property {Object} value the value of the toggle with `name`, `isRefined`, `count`, `onFacetValue` and `offFacetValue`
* @property {function} createURL the function to create a url for the next state
* @property {function} refine updates to the next state
* @property {Object} connectorParams all `CustomToggleWidgetOptions` forwarded to rendering
* @property {InstantSearch} instantSearchInstance the instance of instantsearch on which the widget is attached
*/

Expand All @@ -46,11 +47,13 @@ Full documentation available at https://community.algolia.com/instantsearch.js/c
export default function connectToggle(renderFn) {
checkRendering(renderFn, usage);

return ({
attributeName,
label,
values: userValues = {on: true, off: undefined},
}) => {
return options => {
const {
attributeName,
label,
values: userValues = {on: true, off: undefined},
} = options;

if (!attributeName || !label) {
throw new Error(usage);
}
Expand Down Expand Up @@ -128,6 +131,7 @@ export default function connectToggle(renderFn) {
createURL: this._createURL,
refine: this.toggleRefinement,
instantSearchInstance,
connectorParams: options,
}, true);
},

Expand Down Expand Up @@ -172,6 +176,7 @@ export default function connectToggle(renderFn) {
refine: this.toggleRefinement,
helper,
instantSearchInstance,
connectorParams: options,
}, false);
},
};
Expand Down

0 comments on commit 704a455

Please sign in to comment.