Skip to content
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

Merged
merged 2 commits into from
Sep 25, 2018
Merged

feat(utils): add warn function #3147

merged 2 commits into from
Sep 25, 2018

Conversation

samouss
Copy link
Contributor

@samouss samouss commented Sep 25, 2018

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.

@samouss samouss requested a review from a team September 25, 2018 10:10
@algobot
Copy link
Contributor

algobot commented Sep 25, 2018

Deploy preview for algolia-instantsearch ready!

Built with commit 4385399

https://deploy-preview-3147--algolia-instantsearch.netlify.com

Copy link
Contributor

@Haroenv Haroenv left a 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?

Copy link
Member

@francoischalifour francoischalifour left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's nice!


utils.warn(message);

expect(warn).toHaveBeenCalled();
Copy link
Member

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())

Copy link
Contributor Author

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.

@samouss
Copy link
Contributor Author

samouss commented Sep 25, 2018

@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.

@francoischalifour
Copy link
Member

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 console.warn to this warn utility function.

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 min of undefined" → "Have you declared the attribute attribute as a facet in the dashboard?".

This next step would be a good time to create some sort of package to share common errors that our libraries can throw.

@samouss samouss merged commit 9de87bb into develop Sep 25, 2018
@samouss samouss deleted the feat/warn branch September 25, 2018 13:36
tkrugg added a commit to tkrugg/instantsearch.js that referenced this pull request Oct 23, 2018
<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))
francoischalifour added a commit that referenced this pull request Oct 29, 2018
<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))
francoischalifour added a commit that referenced this pull request Oct 29, 2018
<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))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants