In the Firebase onDisconnect() handler, you can easily use setValue() to update a link to another value or remove() to remove that link.
For setValue() there are also options that include a priority value.
But what is the best practice if you want to update only the priority value, not the value?
Something like onDisconnect().setPriority(Double.MAX_VALUE) missing.
Manually retrieving the current value in the given link again and passing that value to setValue() not only too difficult, but also impossible as the last, quick action when the user disconnected.
Edit:
onDisconnect() cannot be used even with onDisconnect().removeValue() or onDisconnect().setValue(null) in general. The problem is that you cannot disconnect the user manually, right? This may not be the best solution. As of now, you have to wait for the Java GC to clear all Firebase links, and hopefully at least the connection will be closed so that the onDisconnect() callbacks are fired, is this won?
source share