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.
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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["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```"]]