I have been working on a way to remove an item from my $firebaseArray called "boxes".
Here is the "remove" function:
function remove(boxJson) {
return boxes.$remove(boxJson);
}
Although it gets removed, I noticed that it immediately reappears:
https://i.stack.imgur.com/FnVeX.png
This is the process for fetching the array:
function getBoxes(screenIndex) {
var boxesRef = screens
.child("s-" + screenIndex)
.child("boxes");
return $firebaseArray(boxesRef);
}
I initially thought I might be holding multiple references to the firebaseArray causing this issue, but then realized Firebase should handle it. Any insights?
UPDATE
As a temporary solution, when I manually delete twice with a timeout, it seems to work as expected:
function removeForce(screenIndex, boxId) {
setTimeout(function () {
API.removeBox(screenIndex, boxId);
}, 1000);
return API.removeBox(screenIndex, boxId);
}
The structure of the API.removeBox function:
function removeBox(screenIndex, boxId) {
var boxRef = screens
.child("s-" + screenIndex)
.child("boxes")
.child(boxId);
return boxRef.remove();
}