Stay organized with collections
Save and categorize content based on your preferences.
firebase::database::ValueListener
This is an abstract class.
#include <listener.h>
Value listener interface.
Summary
Subclasses of this listener class can be used to receive events about data changes at a location. Attach the listener to a location using DatabaseReference::AddValueListener() or Query::AddValueListener(), and OnValueChanged() will be called once immediately, and again when the value changes.
Public functions
|
OnCancelled(const Error & error, const char *error_message)=0
|
virtual void
This method will be triggered in the event that this listener either failed at the server, or is removed as a result of the security and Firebase rules.
|
OnValueChanged(const DataSnapshot & snapshot)=0
|
virtual void
This method will be called with a snapshot of the data at this location each time that data changes.
|
Public functions
OnCancelled
virtual void OnCancelled(
const Error & error,
const char *error_message
)=0
This method will be triggered in the event that this listener either failed at the server, or is removed as a result of the security and Firebase rules.
Details |
Parameters |
error
|
A code corresponding to the error that occurred.
|
error_message
|
A description of the error that occurred.
|
|
OnValueChanged
virtual void OnValueChanged(
const DataSnapshot & snapshot
)=0
This method will be called with a snapshot of the data at this location each time that data changes.
Details |
Parameters |
snapshot
|
The current data at the location.
|
|
~ValueListener
virtual ~ValueListener()
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-01-23 UTC.
[null,null,["Last updated 2024-01-23 UTC."],[],[],null,["# firebase::database::ValueListener Class Reference\n\nfirebase::database::ValueListener\n=================================\n\n\n**This is an abstract class.**\n\n\n`#include \u003clistener.h\u003e`\n\nValue listener interface.\n\nSummary\n-------\n\nSubclasses of this listener class can be used to receive events about data changes at a location. Attach the listener to a location using [DatabaseReference::AddValueListener()](/docs/reference/cpp/class/firebase/database/query#classfirebase_1_1database_1_1_query_1aeb583c0c607b01692f9aaa9a59432810) or [Query::AddValueListener()](/docs/reference/cpp/class/firebase/database/query#classfirebase_1_1database_1_1_query_1aeb583c0c607b01692f9aaa9a59432810), and [OnValueChanged()](/docs/reference/cpp/class/firebase/database/value-listener#classfirebase_1_1database_1_1_value_listener_1a02ce2f03e20564a124b5d290158494a8) will be called once immediately, and again when the value changes.\n\n| ### Constructors and Destructors ||\n|---|---|\n| [~ValueListener](#classfirebase_1_1database_1_1_value_listener_1ae594401b91d5fcf0020241f8e2a09d3d)`()` ||\n\n| ### Public functions ||\n|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [OnCancelled](#classfirebase_1_1database_1_1_value_listener_1a8f97aa3b6378c57d0d4b8cf853a95538)`(const `[Error](/docs/reference/cpp/namespace/firebase/database#namespacefirebase_1_1database_1aacf6e57cd8d76d485eeb3907fc298231)` & error, const char *error_message)=0` | `virtual void` This method will be triggered in the event that this listener either failed at the server, or is removed as a result of the security and Firebase rules. |\n| [OnValueChanged](#classfirebase_1_1database_1_1_value_listener_1a02ce2f03e20564a124b5d290158494a8)`(const `[DataSnapshot](/docs/reference/cpp/class/firebase/database/data-snapshot#classfirebase_1_1database_1_1_data_snapshot)` & snapshot)=0` | `virtual void` This method will be called with a snapshot of the data at this location each time that data changes. |\n\nPublic functions\n----------------\n\n### OnCancelled\n\n```c++\nvirtual void OnCancelled(\n const Error & error,\n const char *error_message\n)=0\n``` \nThis method will be triggered in the event that this listener either failed at the server, or is removed as a result of the security and Firebase rules.\n\n\u003cbr /\u003e\n\n| Details ||\n|------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Parameters | |-----------------|--------------------------------------------------| | `error` | A code corresponding to the error that occurred. | | `error_message` | A description of the error that occurred. | |\n\n### OnValueChanged\n\n```c++\nvirtual void OnValueChanged(\n const DataSnapshot & snapshot\n)=0\n``` \nThis method will be called with a snapshot of the data at this location each time that data changes.\n\n\u003cbr /\u003e\n\n| Details ||\n|------------|-------------------------------------------------------------------------------------------------------|\n| Parameters | |------------|-----------------------------------| | `snapshot` | The current data at the location. | |\n\n### \\~ValueListener\n\n```c++\nvirtual ~ValueListener()\n```"]]