Commit acc127c
authored
feat(netwatch): Add browser support for rough network changes (online/offline) (#14)
## Description
Uses `window.navigator.onLine` and [`window.addEventListener("online",
...)` and
friends](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/onLine#listening_for_changes_in_network_status)
to listen for network changes.
## Notes & open questions
I tested this manually in firefox, chromium and gnome's WebKit-based
browser.
~~I'm not sure how easy it would be to set up automated testing for this
:S~~
Pretty hard. I've at least made sure there's a node.js smoke test for
this, so that *using* the API doesn't fail, even if the underlying
`navigator.onLine` or "online"/"offline" event listener APIs don't
exist.
Even if this were run in a browser, it'd be hard to trigger
online/offline.
The code generally falls back to not doing monitoring when the platform
doesn't support it (e.g. node.js). In that case, you just won't get any
events.
## Change checklist
- [x] Self-review.
- [x] Test1 parent 58ca29f commit acc127c
17 files changed
Lines changed: 1073 additions & 48 deletions
File tree
- .cargo
- .github/workflows
- netwatch
- src
- interfaces
- netmon
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
150 | 184 | | |
151 | 185 | | |
152 | 186 | | |
| |||
0 commit comments