-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rework of InstantSearch extensionality [BC break] #822
Conversation
76b47f5
to
9f9e200
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks very good! I think you should provide some tooling to be able to fetch a specific widget config based on some predicate (attribute name or kind of widget) because otherwise it could be tedious to update.
Feel free to discard my comments if they don't fit with your coding style.
js/algoliasearch/instantsearch.js
Outdated
allWidgetConfiguration = algoliaHookBeforeWidgetInitialization(allWidgetConfiguration); | ||
} | ||
|
||
for (var widgetType in allWidgetConfiguration) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd reuse $.each
here too.
js/algoliasearch/instantsearch.js
Outdated
|
||
for (var widgetType in allWidgetConfiguration) { | ||
if (Array.isArray(allWidgetConfiguration[widgetType]) === true) { | ||
for (var i = 0; i < allWidgetConfiguration[widgetType].length; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd reuse $.each
here too.
js/algoliasearch/instantsearch.js
Outdated
addWidget(search, widgetType, widgetConfig); | ||
} | ||
|
||
continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd replace that with an else statement two lines after.
var widgetType = widgetInfo[0], | ||
widgetConfig = widgetInfo[1]; | ||
|
||
if (typeof allWidgetConfiguration[widgetType] === 'undefined') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd go for:
if (typeof allWidgetConfiguration[widgetType] === 'undefined') {
allWidgetConfiguration[widgetType] = [widgetConfig];
} else {
allWidgetConfiguration[widgetType].push(widgetConfig);
}
9f9e200
to
388de6a
Compare
Implements #821