Skip to content

Conversation

digitaljohn
Copy link

@digitaljohn digitaljohn commented Sep 25, 2019

Which issue, if any, is this issue related to?

None

Is there anything in the PR that needs further explanation?

Adding a changed property so it's easy to detect when the data changes.

Elements to look at before this is ready:

  • Hook dependencies are causing warnings react-hooks/exhaustive-dep.
  • If payload is specified in dependencies the tests hang.
  • Do the offending dependencies actually cause an issue?
  • Add hooks linting

@digitaljohn digitaljohn added the enhancement New feature or request label Sep 25, 2019
@digitaljohn digitaljohn self-assigned this Sep 25, 2019
@digitaljohn digitaljohn added the WIP Do not merge label Sep 25, 2019
@digitaljohn digitaljohn added the help wanted Extra attention is needed label Sep 25, 2019
@digitaljohn digitaljohn removed WIP Do not merge help wanted Extra attention is needed labels Sep 25, 2019
@digitaljohn
Copy link
Author

Managed to get 100% code coverage 👍

@digitaljohn
Copy link
Author

Changed change property to input argument callback. More useful.

Copy link
Contributor

@marcelkornblum marcelkornblum left a comment

Choose a reason for hiding this comment

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

Really smart, but does it need extra thinking by the implementer? See above.

README.md Outdated
- `pollInterval` - How often to re-request updated data. Pass 0 to disable polling (the default behaviour).
- `payload` - A data object to send in the request. If we are performing a GET request, it is appended into the querystring (e.g. `?keywords=hello`). If it is a POST request it is sent in the request body as JSON.
- `method` - Set the request type, either `get` or `post`. (defaults to `get`)
- `changed`: A function to call if the data actually changed during the request.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be good to state that no redraw will happen unless the data is changed, to make it explicit. Is there any sort of tradeoff for this? does it mean e.g. big data sets will be stored in memory twice (once by this tool and once by the calling app that uses this tool)? Does that need design consideration by whoever uses this tool?

Copy link
Author

Choose a reason for hiding this comment

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

I've made the behaviour optional. If a change option is not specified, no comparison will be done. Also expanded in the README.

"dependencies": {
"axios": "^0.19.0"
"axios": "^0.19.0",
"lodash.isequal": "^4.5.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

seems a shame to bring any lodash in :/

Mapbox elected to use their own function: mapbox/mapbox-gl-js#5744

Worth considering? Genuine open question / mind.

Copy link
Author

Choose a reason for hiding this comment

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

I'm bringing in just a single function though, not the whole package?

Copy link
Contributor

Choose a reason for hiding this comment

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

so was mapbox. definitely prefer this to the whole lib and it's certinaly not a blocker, i just wondered if it was worth discussing

@digitaljohn
Copy link
Author

@marcelkornblum I added more documentation on the risks with using change.

Co-Authored-By: Marcel Kornblum <marcelkornblum@users.noreply.github.com>
@digitaljohn digitaljohn merged commit aeb2ddc into master Sep 26, 2019
@digitaljohn digitaljohn deleted the changed-property branch September 26, 2019 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants