network
Die Übersetzung dieser Seite fehlt oder ist veraltet, daher wird sie auf Englisch angezeigt. Auf Englisch lesen
Show an offline hint or defer a large download using the platform network state. Always handle the actual request result as well.
Display an offline hint
import { Text, network } from 'kuito';
network.state.value; // the state now, synchronously
await network.refresh(); // the same, read off the JS thread
function OfflineBanner() {
return <Text>{network.state.value.isInternetReachable ? '' : 'You are offline'}</Text>;
}Behavior and limits
network.state tracks connection type, connection status, reachability and cost. refresh() gets a fresh snapshot asynchronously. Reachability is the platform verdict, not a probe of your server. On iOS a satisfied route can still lead to a captive portal. A connected device can still fail a request, so network status must not replace error handling. Monitoring starts while the signal is observed and stops when the last observer leaves.
Continue
Read Web apis for the related workflow. The API reference lists every method, option, event and return type.
Referenz
Exporte 6
Methoden, Konstanten und Typen, die dieser native Namespace bereitstellt.
type
NetworkStateTypeThe transport of the network the system routes traffic through.typeCellularGenerationThe radio's generation on a cellular network: '2g', '3g', '4g' or '5g'.typeNetworkDetailsWhether the current network costs the user money, and its generation on cellular.typeNetworkStateThe device's network as the app can use it now: its kind, whether it is connected, and whether the internet answers.valuestateThe network now.functionrefreshRe-reads the state off the JS thread, for a check right before a request.Generiert aus den öffentlichen TypeScript-Deklarationen: Signaturen, Props und Standardwerte stammen aus der geprüften Quelle, Beschreibungen aus deren JSDoc. Kein Standardwert ist erfunden.