new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

TanStack Query · Reference · all subjects

onlinemanager

7 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

OnlineManager default behavior and network detection

The OnlineManager manages the online state within TanStack Query. By default, it assumes an active network connection and listens to the online and offline events on the window object to detect changes. It starts with online: true and only updates the status based on these events, rather than using navigator.onLine, to reduce false negatives.

OnlineManager available methods

The OnlineManager provides four methods: setEventListener, subscribe, setOnline, and isOnline.

onlineManager.setEventListener

setEventListener accepts a callback that receives a setOnline function. The callback should set up a custom event listener and return an unsubscribe function. Example: onlineManager.setEventListener((setOnline) => { return NetInfo.addEventListener((state) => { setOnline(!!state.isConnected) }) })

onlineManager.subscribe

subscribe accepts a callback that receives the current isOnline boolean value. It returns an unsubscribe function that can be called to stop listening to changes in the online state. Example: const unsubscribe = onlineManager.subscribe((isOnline) => { console.log('isOnline', isOnline) })

onlineManager.setOnline

setOnline manually sets the online state. It accepts a single option: online (boolean, required). Example: onlineManager.setOnline(true) sets to online, onlineManager.setOnline(false) sets to offline.

onlineManager.isOnline

isOnline returns the current online state as a boolean. It takes no parameters. Example: const isOnline = onlineManager.isOnline()

Why navigator.onLine was not used

In previous versions, navigator.onLine was used to determine network status. However, it does not work well in Chromium-based browsers due to numerous issues causing false negatives, which led to Queries being wrongfully marked as offline.

Give your agent this brain