|
5 | 5 | * manually invoked. Instead, one should create a $firebase object and call $asArray |
6 | 6 | * on it: <code>$firebase( firebaseRef ).$asArray()</code>; |
7 | 7 | * |
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 |
9 | 9 | * to notify the array whenever a change has been made at the server: |
10 | 10 | * $$added - called whenever a child_added event occurs |
11 | 11 | * $$updated - called whenever a child_changed event occurs |
|
15 | 15 | * $$process - called immediately after $$added/$$updated/$$moved/$$removed |
16 | 16 | * to splice/manipulate the array and invokes $$notify |
17 | 17 | * |
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: |
19 | 19 | * $$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) |
20 | 21 | * |
21 | 22 | * Instead of directly modifying this class, one should generally use the $extendFactory |
22 | 23 | * method to add or change how methods behave. $extendFactory modifies the prototype of |
|
162 | 163 | */ |
163 | 164 | $keyAt: function(indexOrItem) { |
164 | 165 | var item = this._resolveItem(indexOrItem); |
165 | | - return this._getKey(item); |
| 166 | + return this.$$getKey(item); |
166 | 167 | }, |
167 | 168 |
|
168 | 169 | /** |
|
176 | 177 | $indexFor: function(key) { |
177 | 178 | var self = this; |
178 | 179 | // todo optimize and/or cache these? they wouldn't need to be perfect |
179 | | - return this.$list.findIndex(function(rec) { return self._getKey(rec) === key; }); |
| 180 | + return this.$list.findIndex(function(rec) { return self.$$getKey(rec) === key; }); |
180 | 181 | }, |
181 | 182 |
|
182 | 183 | /** |
|
349 | 350 | * @returns {string||null} |
350 | 351 | * @private |
351 | 352 | */ |
352 | | - _getKey: function(rec) { |
| 353 | + $$getKey: function(rec) { |
353 | 354 | return angular.isObject(rec)? rec.$id : null; |
354 | 355 | }, |
355 | 356 |
|
|
364 | 365 | * @private |
365 | 366 | */ |
366 | 367 | $$process: function(event, rec, prevChild) { |
367 | | - var key = this._getKey(rec); |
| 368 | + var key = this.$$getKey(rec); |
368 | 369 | var changed = false; |
369 | 370 | var pos; |
370 | 371 | switch(event) { |
|
0 commit comments