Skip to content
This repository was archived by the owner on Mar 29, 2022. It is now read-only.

Remove triggers two value events #6

Closed
ginovva320 opened this issue Jun 13, 2015 · 0 comments
Closed

Remove triggers two value events #6

ginovva320 opened this issue Jun 13, 2015 · 0 comments

Comments

@ginovva320
Copy link

Using a value listener on a node that's being removed triggers the callback twice. The first time with an empty snapshot and a second time with the pre-deletion snapshot.

var FirebaseServer = require('firebase-server');
var s = new FirebaseServer(5000, 'dummy.firebaseio.test', {
    states: {
        CA: 'California',
        AL: 'Alabama',
        KY: 'Kentucky'
    }
});

var Firebase = require('firebase');
var client = new Firebase('ws://dummy.firebaseio.test:5000');

// Attaching a value listener to states/CA
client.child('states').child('CA').on('value', function(snap) {
    console.log('Value: ' + snap.val());
});

// After 1 second, remove states/CA
setTimeout(function() {
    console.log('Removing CA');
    client.child('states').child('CA').remove();
}, 1000);

Output:

Value: California
Removing CA
Value: null
Value: California
@urish urish closed this as completed in dc3985d Jul 21, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant