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: add imperative api to refresh state #594
feat: add imperative api to refresh state #594
Conversation
@matt-oakes Just throwing out an alternate solution β we could also make Edit: @mikehardy convinced me the a separate imperative refresh is better: #593 (comment) |
b538e6c
to
6e27175
Compare
Hiya π Friendly reminder that this PR is ready for review π |
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.
Nice! This looks really good, thank you
The only thing I can think of is an addition to the mock
react-native-netinfo/jest/netinfo-mock.js
Line 23 in f05f7dd
RNCNetInfoMock.fetch.mockResolvedValue(defaultState); |
Otherwise looks good?
Sorry for the delay, one of the repos I'm in participates in Google Summer of Code and we had 50 applicants raining PRs on us for the last couple weeks, it has been nutty π€―
Thanks for the review! That's a lot of PRs π Updated the Jest mocks. I'm a bit of a noob when it comes to Jest, so I'm not sure how to test that it works as expected. Let me know if you need further changes. Happy to adjust the PR as needed π |
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 think that's exactly "the needful", this looks great to me, let's go!
# [8.3.0](v8.2.0...v8.3.0) (2022-04-22) ### Features * add imperative api to refresh state ([#594](#594)) ([1d7b751](1d7b751))
π This PR is included in version 8.3.0 π The release is available on: Your semantic-release bot π¦π |
Awesome, thanks so much! |
Fixes #593
Overview
This pull request implements a new imperative API called
refresh
to update NetInfo's state by forcing the native interface to recompute the library's internal state. More detailed in the linked issue πTest Plan
Keeping the tests pretty simple for now:
yarn start:web
to run the example web app.NetInfo.fetch
β observe that no network request is made to retest internet reachability.NetInfo.refresh
β observe that a network request is made to retest internet reachability.There's certainly more that could be done to test this, but personally this is enough to make me confident that this is working as expected.
Screen.Recording.2022-04-05.at.11.43.23.PM.mov