OnDisconnect

class OnDisconnect


The OnDisconnect class is used to manage operations that will be run on the server when this client disconnects. It can be used to add or remove data based on a client's connection status. It is very useful in applications looking for 'presence' functionality. Instances of this class are obtained by calling onDisconnect on a Firebase Database ref.

Summary

Public functions

Task<Void!>

Cancel any disconnect operations that are queued up at this location

Unit

Cancel any disconnect operations that are queued up at this location

Task<Void!>

Remove the value at this location when the client disconnects

Unit

Remove the value at this location when the client disconnects

Task<Void!>
setValue(value: Any?)

Ensure the data at this location is set to the specified value when the client is disconnected (due to closing the browser, navigating to a new page, or network issues).

Unit

Ensure the data at this location is set to the specified value when the client is disconnected (due to closing the browser, navigating to a new page, or network issues).

Task<Void!>
setValue(value: Any?, priority: String?)

Ensure the data at this location is set to the specified value and priority when the client is disconnected (due to closing the browser, navigating to a new page, or network issues).

Task<Void!>
setValue(value: Any?, priority: Double)

Ensure the data at this location is set to the specified value and priority when the client is disconnected (due to closing the browser, navigating to a new page, or network issues).

Unit
setValue(
    value: Any?,
    priority: (Mutable)Map?,
    listener: DatabaseReference.CompletionListener?
)

Ensure the data at this location is set to the specified value and priority when the client is disconnected (due to closing the browser, navigating to a new page, or network issues).

Unit
setValue(
    value: Any?,
    priority: String?,
    listener: DatabaseReference.CompletionListener?
)

Ensure the data at this location is set to the specified value and priority when the client is disconnected (due to closing the browser, navigating to a new page, or network issues).

Unit
setValue(
    value: Any?,
    priority: Double,
    listener: DatabaseReference.CompletionListener?
)

Ensure the data at this location is set to the specified value and priority when the client is disconnected (due to closing the browser, navigating to a new page, or network issues).

Task<Void!>

Ensure the data has the specified child values updated when the client is disconnected

Unit
updateChildren(
    update: (Mutable)Map<String!, Any!>,
    listener: DatabaseReference.CompletionListener?
)

Ensure the data has the specified child values updated when the client is disconnected

Public functions

cancel

fun cancel(): Task<Void!>

Cancel any disconnect operations that are queued up at this location

Returns
Task<Void!>

The Task for this operation.

cancel

fun cancel(listener: DatabaseReference.CompletionListener): Unit

Cancel any disconnect operations that are queued up at this location

Parameters
listener: DatabaseReference.CompletionListener

A listener that will be triggered once the server has cancelled the operations

removeValue

fun removeValue(): Task<Void!>

Remove the value at this location when the client disconnects

Returns
Task<Void!>

The Task for this operation.

removeValue

fun removeValue(listener: DatabaseReference.CompletionListener?): Unit

Remove the value at this location when the client disconnects

Parameters
listener: DatabaseReference.CompletionListener?

A listener that will be triggered once the server has queued up the operation

setValue

fun setValue(value: Any?): Task<Void!>

Ensure the data at this location is set to the specified value when the client is disconnected (due to closing the browser, navigating to a new page, or network issues). This method is especially useful for implementing "presence" systems, where a value should be changed or cleared when a user disconnects so that they appear "offline" to other users.

Parameters
value: Any?

The value to be set when a disconnect occurs or null to delete the existing value

Returns
Task<Void!>

The Task for this operation.

setValue

fun setValue(value: Any?, listener: DatabaseReference.CompletionListener?): Unit

Ensure the data at this location is set to the specified value when the client is disconnected (due to closing the browser, navigating to a new page, or network issues). This method is especially useful for implementing "presence" systems, where a value should be changed or cleared when a user disconnects so that they appear "offline" to other users.

Parameters
value: Any?

The value to be set when a disconnect occurs or null to delete the existing value

listener: DatabaseReference.CompletionListener?

A listener that will be triggered once the server has queued up the operation

setValue

fun setValue(value: Any?, priority: String?): Task<Void!>

Ensure the data at this location is set to the specified value and priority when the client is disconnected (due to closing the browser, navigating to a new page, or network issues). This method is especially useful for implementing "presence" systems, where a value should be changed or cleared when a user disconnects so that they appear "offline" to other users.

Parameters
value: Any?

The value to be set when a disconnect occurs or null to delete the existing value

priority: String?

The priority to be set when a disconnect occurs or null to clear the existing priority

Returns
Task<Void!>

The Task for this operation.

setValue

fun setValue(value: Any?, priority: Double): Task<Void!>

Ensure the data at this location is set to the specified value and priority when the client is disconnected (due to closing the browser, navigating to a new page, or network issues). This method is especially useful for implementing "presence" systems, where a value should be changed or cleared when a user disconnects so that they appear "offline" to other users.

Parameters
value: Any?

The value to be set when a disconnect occurs or null to delete the existing value

priority: Double

The priority to be set when a disconnect occurs

Returns
Task<Void!>

The Task for this operation.

setValue

fun setValue(
    value: Any?,
    priority: (Mutable)Map?,
    listener: DatabaseReference.CompletionListener?
): Unit

Ensure the data at this location is set to the specified value and priority when the client is disconnected (due to closing the browser, navigating to a new page, or network issues). This method is especially useful for implementing "presence" systems, where a value should be changed or cleared when a user disconnects so that they appear "offline" to other users.

Parameters
value: Any?

The value to be set when a disconnect occurs or null to delete the existing value

priority: (Mutable)Map?

The priority to be set when a disconnect occurs

listener: DatabaseReference.CompletionListener?

A listener that will be triggered once the server has queued up the operation

setValue

fun setValue(
    value: Any?,
    priority: String?,
    listener: DatabaseReference.CompletionListener?
): Unit

Ensure the data at this location is set to the specified value and priority when the client is disconnected (due to closing the browser, navigating to a new page, or network issues). This method is especially useful for implementing "presence" systems, where a value should be changed or cleared when a user disconnects so that they appear "offline" to other users.

Parameters
value: Any?

The value to be set when a disconnect occurs or null to delete the existing value

priority: String?

The priority to be set when a disconnect occurs or null to clear the existing priority

listener: DatabaseReference.CompletionListener?

A listener that will be triggered once the server has queued up the operation

setValue

fun setValue(
    value: Any?,
    priority: Double,
    listener: DatabaseReference.CompletionListener?
): Unit

Ensure the data at this location is set to the specified value and priority when the client is disconnected (due to closing the browser, navigating to a new page, or network issues). This method is especially useful for implementing "presence" systems, where a value should be changed or cleared when a user disconnects so that they appear "offline" to other users.

Parameters
value: Any?

The value to be set when a disconnect occurs or null to delete the existing value

priority: Double

The priority to be set when a disconnect occurs

listener: DatabaseReference.CompletionListener?

A listener that will be triggered once the server has queued up the operation

updateChildren

fun updateChildren(update: (Mutable)Map<String!, Any!>): Task<Void!>

Ensure the data has the specified child values updated when the client is disconnected

Parameters
update: (Mutable)Map<String!, Any!>

The paths to update, along with their desired values

Returns
Task<Void!>

The Task for this operation.

updateChildren

fun updateChildren(
    update: (Mutable)Map<String!, Any!>,
    listener: DatabaseReference.CompletionListener?
): Unit

Ensure the data has the specified child values updated when the client is disconnected

Parameters
update: (Mutable)Map<String!, Any!>

The paths to update, along with their desired values

listener: DatabaseReference.CompletionListener?

A listener that will be triggered once the server has queued up the operation