Everything works fine when I use value change listeners. But I wanna make a multiplayer matchmaking functionality for my game. Data gets duplicated when so many users connect at same time. So I want to use Firebase Transaction.
Never worked with Firebase Transaction before. So wrote this code to get the data. But every time it's returning null.
return db.ref('matched').transaction((data) => {
if(data){
console.log(data);
}
}).then((result) => {
console.log(result.snapshot.val())
return result
}).catch((err) => {
console.log(err)
});
Data and result.snapshot.val() both value is null
Matched DB
Where am I doing it wrong?