I was working on a web app and previously noticed that Firebase didn't let me do things like this but was able to find workarounds, but it would be much easier if I could get queries like the following to operate the way I want them to:
var testString='asdf';
firebase.database().ref('testing').once('value', function (snapshot) {
testString=snapshot.val();
console.log('Data val: ' + snapshot.val());
});
console.log('Val after: ' + testString);
When run, this gives me the console output of:
Val after: asdf
Data val: testval
Instead of what I would have expected:
Data val: testval
Val after: asdf
It looks like the Firebase listener doesn't execute the query when it's called. I looked through the documentation, but I didn't find anything that would help me with this issue.
Aucun commentaire:
Enregistrer un commentaire