-
Notifications
You must be signed in to change notification settings - Fork 516
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
feat(utils): add warn function #3147
Conversation
Deploy preview for algolia-instantsearch ready! Built with commit 4385399 https://deploy-preview-3147--algolia-instantsearch.netlify.com |
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.
We have this code in Vue InstantSearch as well. Maybe it should be shared so it's not duplicated across projects?
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.
That's nice!
src/lib/__tests__/utils-test.js
Outdated
|
||
utils.warn(message); | ||
|
||
expect(warn).toHaveBeenCalled(); |
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.
Shouldn't we assert that the warn function is called with the right string prefixed by [InstantSearch.js]:
? (see toHaveBeenCalledWith()
)
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.
Yes we can, will do it.
@Haroenv we can merge it as it is. But once we release both (Vue & IS) we can take a look to extract some of the core logic of InstantSearch (like connectors, utility function etc...) to share them across all flavours. |
There's also some work to be done to make our error messages more explicit to users. A first pass could be done when updating all I'd love to make a smarter pass on our error messages and to detect where the error might come from. Say that you're facing a "cannot retrieve This next step would be a good time to create some sort of package to share common errors that our libraries can throw. |
<a name=2.10.3></a> ## [2.10.3](algolia/instantsearch@v2.10.2...v2.10.3) (2018-10-23) ### Bug Fixes * **InstantSearch:** avoid useless search on addWidgets ([algolia#3178](algolia#3178)) ([961626d](algolia@961626d)) * **numericselector:** default value can be undefined ([algolia#3139](algolia#3139)) ([39d22f5](algolia@39d22f5)) ### Features * **utils:** add warn function ([algolia#3147](algolia#3147)) ([9de87bb](algolia@9de87bb))
<a name="2.10.3"></a> * **deps:** unpin production dependencies ([257ecb7](257ecb7)) * **getRefinements:** provide attributeName for type: query ([6a58b99](6a58b99)), closes [#3205](#3205) * **InstantSearch:** avoid useless search on addWidgets ([#3178](#3178)) ([961626d](961626d)) * **numericselector:** default value can be undefined ([#3139](#3139)) ([39d22f5](39d22f5)) * **utils:** add warn function ([#3147](#3147)) ([9de87bb](9de87bb))
<a name="2.10.3"></a> * **deps:** unpin production dependencies ([257ecb7](257ecb7)) * **getRefinements:** provide attributeName for type: query ([6a58b99](6a58b99)), closes [#3205](#3205) * **InstantSearch:** avoid useless search on addWidgets ([#3178](#3178)) ([961626d](961626d)) * **numericselector:** default value can be undefined ([#3139](#3139)) ([39d22f5](39d22f5)) * **utils:** add warn function ([#3147](#3147)) ([9de87bb](9de87bb))
Summary
This PR introduces a function to display warnings on the page only once (cached by message). I didn't update all the usage of
console.warn
across the codebase to avoid conflict with the 3.0 branch. We can move on latter once the next version is released.