-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Learned from reference app. Address challenge.
Interface goal
Provide a network configuration property that allows users to define a network status check handler, which will provide additional network information if it exists (default null), and a callback that should be invoked with a boolean value. The application will set its isOnline property to this value.
import { Application } from "@nmfs-radfish/radfish";
const app = new Application({
network: {
setIsOnline: async (networkInformation, callback) => {
const response = await fetch("https://example.com")
return callback(response.status === 200);
}
}
});Additional the react-radfish useOfflineStatus hook should add an event listener for the online and offline events.
Warning
application.addEventListener and application.removeEventListener need to be implemented.
const application = useApplication();
const [isOffline, setIsOffline] = useState(!application.isOnline);
const updateOnlineStatus = () => {
setIsOffline(!application.isOnline);
};
useEffect(() => {
updateOnlineStatus();
application.addEventListener("online", updateOnlineStatus);
application.addEventListener("offline", updateOnlineStatus);
return () => {
application.removeEventListener("online", updateOnlineStatus);
application.removeEventListener("offline", updateOnlineStatus);
};
}, []);Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request
Type
Projects
Status
Needs Review