Dzung Nguyen
Dzung Nguyen

Reputation: 3944

Callbacks after updating firebase data

When I update data in Firebase (either manually through the console, or through the web app), it seems that Firebase run some callbacks that make my retrieval app duplicate images.

The retrieval app queries data from Firebase, and put into a table:

var ref = firebase.database().ref("CURETALIASFREE/trial");
        ref.orderByChild("complete").equalTo("true")
           .on("value", function(snapshot) {
           // code that parse snapshot and put into a table.
        }

I have looked into network and consoles in the debug panel, but could not figure out why. enter image description here

Any idea on how to fix this?

Upvotes: 0

Views: 348

Answers (1)

Bob Snyder
Bob Snyder

Reputation: 38289

The on() method attaches the listener function and leaves it attached. The function is called once when attached and then again for any change to the location. If you only want the listener function to execute only one time, use once().

Upvotes: 1

Related Questions