Closed
Description
I read some discussion where Nativescript not yet have background worker and everything is running UI thread. Is there any way to yield the execution to let UI redraw.
Bolow is a good example from one of plugins people implemented to read the phone contacts. If there is 1000 contacts, the UI is totally blocked for few mins. Any idea to yield the execution.
exports.getAllContacts = function(){
return new Promise(function (resolve, reject){
var c = appModule.android.context.getContentResolver().query(android.provider.ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
if(c.getCount() > 0){
var cts = [];
while(c.moveToNext()){
var contactModel = new Contact();
contactModel.initializeFromNative(c);
cts.push(contactModel);
}
c.close();
resolve({
data: cts,
response: "fetch"
});
}
else{
c.close();
resolve({
data: null,
response: "fetch"
});
}
});
};