Last active
November 7, 2019 21:10
Revisions
-
katowulf revised this gist
Oct 15, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ app.factory('FilteredArray', function($firebaseArray) { function FilteredArray(ref, filterFn) { this.filterFn = filterFn; return $firebaseArray.call(this, ref); } FilteredArray.prototype.$$added = function(snap) { var rec = $firebaseArray.prototype.$$added.call(this, snap); -
katowulf revised this gist
Oct 15, 2015 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,8 +14,8 @@ app.factory('FilteredArray', function($firebaseArray) { }); app.controller('...', function($scope, FilteredArray) { var ref = new Firebase('https://kato-books.firebaseio.com/'); $scope.data = FilteredArray(ref, function(rec) { return rec.author !== 'Stephen King'; }) }); -
katowulf revised this gist
Oct 15, 2015 . 1 changed file with 6 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,14 +4,13 @@ app.factory('FilteredArray', function($firebaseArray) { this.filterFn = filterFn; $firebaseArray.call(this, ref); } FilteredArray.prototype.$$added = function(snap) { var rec = $firebaseArray.prototype.$$added.call(this, snap); if( !this.filterFn || this.filterFn(rec) ) { return rec; } }; return $firebaseArray.$extend(FilteredArray); }); app.controller('...', function($scope, FilteredArray) { -
katowulf revised this gist
Oct 15, 2015 . 1 changed file with 0 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,10 +10,6 @@ app.factory('FilteredArray', function($firebaseArray) { if( !this.filterFn || this.filterFn(rec) ) { return rec; } } }); }); -
katowulf revised this gist
Oct 15, 2015 . 1 changed file with 5 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,10 @@ // this will be much more efficient than $watch() app.factory('FilteredArray', function($firebaseArray) { function FilteredArray(ref, filterFn) { this.filterFn = filterFn; $firebaseArray.call(this, ref); } return $firebaseArray.$extend(FilteredArray, { $$added: function(snap) { var rec = $firebaseArray.prototype.$$added.call(this, snap); if( !this.filterFn || this.filterFn(rec) ) { -
katowulf revised this gist
May 11, 2015 . 2 changed files with 0 additions and 17 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,16 +0,0 @@ This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,3 @@ // this will be much more efficient than $watch() app.factory('FilteredArray', function($firebaseArray) { return $firebaseArray.$extend({ -
katowulf created this gist
May 11, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ // this should work for small numbers, less than hundreds app.controller('...', function($scope, $firebaseArray) { $scope.data = []; var ref = new Firebase(...); var arr = $firebaseArray(ref); arr.$watch(rebuild); function rebuild() { $scope.data.length = 0; angular.forEach(rec) { if( rec.foo !== 'bar' ) { $scope.data.push() } } } }); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ // this will be much more efficient than $watch() app.factory('FilteredArray', function($firebaseArray) { return $firebaseArray.$extend({ $$added: function(snap) { var rec = $firebaseArray.prototype.$$added.call(this, snap); if( !this.filterFn || this.filterFn(rec) ) { return rec; } }, filter: function(filterFn) { this.filterFn = filterFn; } }); }); app.controller('...', function($scope, FilteredArray) { var ref = new Firebase(...); $scope.data = FilteredArray(ref, function(rec) { return rec.foo !== 'bar'; }) });