javascript - Performance limitations of angular filters on mobile -
i have 3000 objects each number of properties creating 72,000 line 2mb json file.
the json database of objects need filtered text search filter , matching values against array of values.
in initial view perform in service
:
this.loadjsonfile = function(url, process) { var defer = $q.defer(); if (angular.isdefined(cache[url])) { if (angular.isdefined(cache[url]['then'])) { return cache[url]; } defer.resolve(cache[url]); return defer.promise; } $http.get(url).success(function(data) { if (process) { data = process(data); } cache[url] = data; defer.resolve(data); }).error(function(err){ defer.reject(err); }); cache[url] = defer.promise; return defer.promise; }; this.getexercises = function() { return this.loadjsonfile('data/exercises.json'); };
and in controller results exposed $scope
by:
api.getexcercises().then(function(data) { $scope.allexercises = data.results; });
i limit results :
$scope.limit = 56;
previously have stayed away calling server every time need search number of calls high! works ok on ipad air 2 , iphone 6 there plenty of power, on galaxy tab pretty poor.
i need on strategy of exposing limited number of results $scope
think shear amount of data being filtered , churned around causing poor performance. fine search / filter function being run , breaking seamless nature of live search feature long when results exposed $scope
(following loading screen say) performance sharp.
looking server situation not keen on hitting parse.com server not angular friendly, async nature of firebase might work. have uploaded json , attached data $scope via :
var ref = new firebase("https://url_here.firebaseio.com/results"); $scope.allexercises = $firebasearray(ref);
which works pretty local json method. wonder if possible perform following using firebase?
- load initial 50 results ordered name.
- when typing in text search query performed , $scope delivered results.
- when adding values filter array data on firebase queried against values , results exposed
$scope
.
please take time go through firebase guide. prevent many questions, answered there already.
yup, like:
ref.orderbychild('name').limittofirst(50);
you'd have run query like:
ref.orderbychild('name').startat(searchstring).limittofirst(50);
note firebase querying not support wildcard searches. see guide's section on querying more info.
Comments
Post a Comment