pub fn on_value_changed(
db_location_reference: &DatabaseReference,
callback: &'static dyn Fn(JsValue),
)
Expand description
Registers a [callback] to be executed every time some data at the specified DatabaseReference changes. Note: This closure will be called the first time the data becomes available.
§Examples
use firebase_js::database::{get_database, get_ref, on_value_changed};
let db = get_database(&app, "https://my-project.firebaseio.com");
let db_ref = get_ref(&db, "users/1234");
on_value_changed(&db_ref, |data| {
// do something with data
});
§WIP:
- Unsubscribing does not work yet
- Potential for convenienve func to take String instead of &DatabaseReference