How-to
Website
Web app
Desktop / phone
Show what the network is doing
network tells a page whether it is online, how fast the line is and whether the reader asked to save data, so the page can change what it does on a slow line or none at all. This inbox warns when the browser is offline and when data saver is on:
page Inbox(path: "/inbox", title: "Inbox", description: "Your messages.") {
Heading("Inbox").h1
if !network.online { Alert("You are offline.").warning }
if network.saveData { Text("Data saver is on.").muted }
}
How it works
Like viewport, network is a browser value that keeps itself current: each if that reads it is drawn again when the connection changes, with nothing to subscribe to.
| Member | What it is |
|---|---|
|
|
Whether the browser has a connection |
|
|
How fast it is: |
|
|
Whether the reader asked to save data |
|
|
The estimated bandwidth, in megabits per second |
|
|
How many writes wait for the connection, when the site works offline (Offline) |
|
|
The kept writes the server refused once they were sent, each |