I have a js array that will cause some issue to my electron app due to it’s size, it will contain about 53000 objects. To avoid performances issues, how I can split it when data are loaded on application start? at the moment I’m getting the data from ad odbc access file and pushing it to an array on the front-end using vuejs.
background.js
ipcMain.on('init', (event, ...args) => {
let suppliersData = false
let clientsData = false
suppliersdb.query('SELECT * FROM FANFOR0F_1')
.then( (results) => {
console.log(results.length)
//
suppliersData = true
//result.NEMA = result.NEMA.replace('ยง', '@')
event.sender.send('suppliersData', results)
}).catch( e => {
console.log(e)
event.sender.send('databaseUpdateError', e)
})
clientsdb.query('SELECT * FROM PDECON0F_1')
.then( (results) => {
console.log(results.length)
clientsData = true
event.sender.send('clientsData', results)
}).catch( e => {
console.log(e)
event.sender.send('databaseUpdateError', e)
})
//
if( suppliersData && clientsData ){
event.sender.send('databaseUpdateCompleted')
}
})
vue frontend-loading time mounted()
hook
window.ipcRenderer.send('init')
window.ipcRenderer.receive('suppliersData', (data) => {
this.suppliersDataAvailable = true
this.store.suppliers = data
})
window.ipcRenderer.receive('clientsData', (data) => {
console.log(data)
this.clientsDataAvailable = true
this.store.clients = data
})
My idea is to split it into different pages or lazyload the content when page is scrolled, I’m implementing rxdb to have a local copy of the data and decrease loading time on application startup. Any suggestion will be appreciated.
2
Answers
I have a solution:
You can insert any natural number in arrayLengths and it will work.
You can find all the arrays in arrays array
i found an easier solution that involves .slice() method:
everything works the same. Except you don’t need that temporary array anymore.