import ApiEvents from './events/ApiEvents';
import { firebaseRef } from './appconfig';

var ref = firebaseRef.child('notes');

var API = {
  start() {
    ref.on('child_added', (snapshot) => {
      var noteName = snapshot.key();
      var note = snapshot.val();
      ApiEvents.noteAdded(noteName, note);
    });

    ref.on('child_removed', (snapshot) => {
      var noteName = snapshot.key();
      ApiEvents.noteRemoved(noteName);
    });

    ref.on('child_changed', (snapshot) => {
      var noteName = snapshot.key();
      var note = snapshot.val();
      ApiEvents.noteChanged(noteName, note);
    });
  },

  stop() {
    ref.off('child_added');
    ref.off('child_removed');
    ref.off('child_changed');
  },

  createNote(data) {
    ref.push(data);
  },

  deleteNote(name) {
    ref.child(name).remove();
  },

  updateNote(name, data) {
    ref.child(name).update(data);
  },
};

export default API;

@@ -85,17 +85,21 @@
 ';%0A%0Avar 
-r
+noteR
 ef = fir
@@ -148,25 +148,29 @@
 art() %7B%0A    
-r
+noteR
 ef.on('child
@@ -312,33 +312,37 @@
 );%0A    %7D);%0A%0A    
-r
+noteR
 ef.on('child_rem
@@ -449,25 +449,29 @@
    %7D);%0A%0A    
-r
+noteR
 ef.on('child
@@ -637,25 +637,29 @@
 top() %7B%0A    
-r
+noteR
 ef.off('chil
@@ -665,33 +665,37 @@
 ld_added');%0A    
-r
+noteR
 ef.off('child_re
@@ -707,17 +707,21 @@
 ');%0A    
-r
+noteR
 ef.off('
@@ -768,17 +768,21 @@
 ) %7B%0A    
-r
+noteR
 ef.push(
@@ -811,33 +811,37 @@
 ote(name) %7B%0A    
-r
+noteR
 ef.child(name).r
@@ -886,17 +886,21 @@
 ) %7B%0A    
-r
+noteR
 ef.child

Rename ref to noteRef in API