问题描述:

I am making an application in ionic framework, which makes web requests through a Web service. I have about 10,000 records, and maybe in a week 200 records and so on are increased. my problem is in the time required to load the information. there are sections within my application that takes too long to load the application, increasing the use of CPU and battery. if I keep records as .json the size is around 10Mb

I compress and decompress these records turning them into string and storing them in localStorage with the library "LZString". but apparently the use of this library consumes resources besides the "JSON.parse". that's how I was doing it with about 5000 records.

if I have kept records, unzip:

desc = LZString.decompress (window.localStorage.getItem ( 'var')) || [];

JSON.parse return (dec); // Desc has 5000 records

if I make the request for the first time, compress:

window.localStorage.setItem ( 'var' LZString.compress (JSON.stringify (objJson))); // ObjJson 5000 records.

before compressing:

Total: 4.82 MB

after compressing:

Total: 0.55MB

I can do to optimize the performance of my application and compress the information or something ?.

网友答案:

You could try breaking the items up in to smaller chunks/pages, maybe accessing 100 records at a time.

Another option would be to display the loading indicator while loading the data.

http://ionicframework.com/docs/api/service/$ionicLoading/

Please follow up if I am misunderstanding your question.

Thanks, Dan

相关阅读:
Top