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

Commit 0c27be1

Browse files
committed
Merge branch 'master' into kato-protractor
2 parents 2e318fe + f8ca2ec commit 0c27be1

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/FirebaseArray.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* manually invoked. Instead, one should create a $firebase object and call $asArray
66
* on it: <code>$firebase( firebaseRef ).$asArray()</code>;
77
*
8-
* Internally, the $firebase object depends on this class to provide 5 methods, which it invokes
8+
* Internally, the $firebase object depends on this class to provide 5 $$ methods, which it invokes
99
* to notify the array whenever a change has been made at the server:
1010
* $$added - called whenever a child_added event occurs
1111
* $$updated - called whenever a child_changed event occurs
@@ -15,8 +15,9 @@
1515
* $$process - called immediately after $$added/$$updated/$$moved/$$removed
1616
* to splice/manipulate the array and invokes $$notify
1717
*
18-
* Additionally, there is one more method of interest to devs extending this class:
18+
* Additionally, these methods may be of interest to devs extending this class:
1919
* $$notify - triggers notifications to any $watch listeners, called by $$process
20+
* $$getKey - determines how to look up a record's key (returns $id by default)
2021
*
2122
* Instead of directly modifying this class, one should generally use the $extendFactory
2223
* method to add or change how methods behave. $extendFactory modifies the prototype of
@@ -169,7 +170,7 @@
169170
*/
170171
$keyAt: function(indexOrItem) {
171172
var item = this._resolveItem(indexOrItem);
172-
return this._getKey(item);
173+
return this.$$getKey(item);
173174
},
174175

175176
/**
@@ -186,7 +187,7 @@
186187
// evaluate whether our key is cached and, if so, whether it is up to date
187188
if( !cache.hasOwnProperty(key) || self.$keyAt(cache[key]) !== key ) {
188189
// update the hashmap
189-
var pos = self.$list.findIndex(function(rec) { return self._getKey(rec) === key; });
190+
var pos = self.$list.findIndex(function(rec) { return self.$$getKey(rec) === key; });
190191
if( pos !== -1 ) {
191192
cache[key] = pos;
192193
}
@@ -364,7 +365,7 @@
364365
* @returns {string||null}
365366
* @private
366367
*/
367-
_getKey: function(rec) { //todo rename this to $$getId
368+
$$getKey: function(rec) {
368369
return angular.isObject(rec)? rec.$id : null;
369370
},
370371

@@ -379,7 +380,7 @@
379380
* @private
380381
*/
381382
$$process: function(event, rec, prevChild) {
382-
var key = this._getKey(rec);
383+
var key = this.$$getKey(rec);
383384
var changed = false;
384385
var curPos;
385386
switch(event) {
@@ -448,7 +449,7 @@
448449
if( i === 0 ) { i = this.$list.length; }
449450
}
450451
this.$list.splice(i, 0, rec);
451-
this._indexCache[this._getKey(rec)] = i;
452+
this._indexCache[this.$$getKey(rec)] = i;
452453
return i;
453454
},
454455

@@ -487,7 +488,7 @@
487488
// a $id or even a $id that is in the array, it must be an actual record
488489
// the fastest way to determine this is to use $getRecord (to avoid iterating all recs)
489490
// and compare the two
490-
var key = this._getKey(indexOrItem);
491+
var key = this.$$getKey(indexOrItem);
491492
var rec = this.$getRecord(key);
492493
return rec === indexOrItem? rec : null;
493494
}

0 commit comments

Comments
 (0)