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

Commit 5935f84

Browse files
committed
firebase.js: Fixes comments and URL in $firebase error.
utils.js: reject promise if once fails chat.js: removed superfluous transaction code priority.js: fix comment referring to FirebaseArray vs FirebaseObject FirebaseArray.js,FirebaseObject.js: renamed resolve method to initComplete for clarity
1 parent 2fbedcb commit 5935f84

File tree

6 files changed

+19
-43
lines changed

6 files changed

+19
-43
lines changed

src/FirebaseArray.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@
584584
ref.off('child_changed', updated);
585585
ref.off('child_removed', removed);
586586
firebaseArray = null;
587-
resolve(err||'destroyed');
587+
initComplete(err||'destroyed');
588588
}
589589
}
590590

@@ -603,12 +603,12 @@
603603
$log.warn('Storing data using array indices in Firebase can result in unexpected behavior. See https://www.firebase.com/docs/web/guide/understanding-data.html#section-arrays-in-firebase for more information.');
604604
}
605605

606-
resolve(null, $list);
607-
}, resolve);
606+
initComplete(null, $list);
607+
}, initComplete);
608608
}
609609

610-
// call resolve(), do not call this directly
611-
function _resolveFn(err, result) {
610+
// call initComplete(), do not call this directly
611+
function _initComplete(err, result) {
612612
if( !isResolved ) {
613613
isResolved = true;
614614
if( err ) { def.reject(err); }
@@ -654,10 +654,10 @@
654654

655655
var isResolved = false;
656656
var error = batch(function(err) {
657-
_resolveFn(err);
657+
_initComplete(err);
658658
firebaseArray.$$error(err);
659659
});
660-
var resolve = batch(_resolveFn);
660+
var initComplete = batch(_initComplete);
661661

662662
var sync = {
663663
destroy: destroy,

src/FirebaseObject.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@
404404
sync.isDestroyed = true;
405405
ref.off('value', applyUpdate);
406406
firebaseObject = null;
407-
resolve(err||'destroyed');
407+
initComplete(err||'destroyed');
408408
}
409409
}
410410

@@ -415,12 +415,12 @@
415415
$log.warn('Storing data using array indices in Firebase can result in unexpected behavior. See https://www.firebase.com/docs/web/guide/understanding-data.html#section-arrays-in-firebase for more information. Also note that you probably wanted $FirebaseArray and not $FirebaseObject.');
416416
}
417417

418-
resolve(null);
419-
}, resolve);
418+
initComplete(null);
419+
}, initComplete);
420420
}
421421

422-
// call resolve(); do not call this directly
423-
function _resolveFn(err) {
422+
// call initComplete(); do not call this directly
423+
function _initComplete(err) {
424424
if( !isResolved ) {
425425
isResolved = true;
426426
if( err ) { def.reject(err); }
@@ -440,7 +440,7 @@
440440
}
441441
});
442442
var error = batch(firebaseObject.$$error, firebaseObject);
443-
var resolve = batch(_resolveFn);
443+
var initComplete = batch(_initComplete);
444444

445445
var sync = {
446446
isDestroyed: false,

src/firebase.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
return function() {
99
throw new Error('$firebase has been removed. You may instantiate $FirebaseArray and $FirebaseObject ' +
1010
'directly now. For simple write operations, just use the Firebase ref directly. ' +
11-
'See CHANGELOG for details and migration instructions: https://www.firebase.com/docs/web/changelog.html');
11+
'See the AngularFire 1.0.0 changelog for details: https://www.firebase.com/docs/web/changelog.html');
1212
};
1313
});
1414

src/utils.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,8 @@
449449
}
450450
});
451451
ref.ref().update(dataCopy, utils.makeNodeResolver(def));
452+
}, function(err) {
453+
def.reject(err);
452454
});
453455
}
454456
return def.promise;
@@ -478,6 +480,8 @@
478480
def.reject(err);
479481
}
480482
);
483+
}, function(err) {
484+
def.reject(err);
481485
});
482486
}
483487
return def.promise;

tests/protractor/chat/chat.js

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ app.controller('ChatCtrl', function Chat($scope, $FirebaseObject, $FirebaseArray
33
// Get a reference to the Firebase
44
var chatFirebaseRef = new Firebase('https://angularFireTests.firebaseio-demo.com/chat');
55
var messagesFirebaseRef = chatFirebaseRef.child("messages").limitToLast(2);
6-
var numMessagesFirebaseRef = chatFirebaseRef.child("numMessages");
76

87
// Get AngularFire sync objects
98

@@ -37,33 +36,6 @@ app.controller('ChatCtrl', function Chat($scope, $FirebaseObject, $FirebaseArray
3736

3837
// Reset the message input
3938
$scope.message = "";
40-
41-
// Increment the messages count by 1
42-
numMessagesFirebaseRef.transaction(function (currentCount) {
43-
if (currentCount === null) {
44-
// Set the initial value
45-
return 1;
46-
}
47-
else if (currentCount < 0) {
48-
// Return undefined to abort the transaction
49-
return;
50-
}
51-
else {
52-
// Increment the messages count by 1
53-
return currentCount + 1;
54-
}
55-
}, function (error, committed, snapshot) {
56-
if( error ) {
57-
verify(false, "Messages count transaction errored: " + error);
58-
}
59-
else if(!committed) {
60-
// Handle aborted transaction
61-
verify(false, "Messages count transaction unexpectedly aborted.")
62-
}
63-
else {
64-
// Success
65-
}
66-
});
6739
}
6840
};
6941

tests/protractor/priority/priority.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ app.controller('PriorityCtrl', function Chat($scope, $FirebaseArray, $FirebaseOb
3030
var newItem = new $FirebaseObject(ref);
3131

3232
newItem.$loaded().then(function (data) {
33-
verify(newItem === data, '$FirebaseArray.$loaded() does not return correct value.');
33+
verify(newItem === data, '$FirebaseObject.$loaded() does not return correct value.');
3434

3535
// Update the message's priority
3636
newItem.$priority = priority;

0 commit comments

Comments
 (0)