@dominic this should give you an idea how to solve your problem, I just wrote it down maybe you have to adjust something a little bit and it’s not a finished solution
const fs = require('fs');
...
socketNotificationReceived: function(notification, payload) {
if(notification === 'START'){
this.config = payload;
this.readData();
setInterval(() => {
this.readData();
}, this.config.updateInterval);
}
},
readData: function(){
//to read a file to do the following
fs.readFile('YOUR FILE PATH', (err, data) => {
if (err) throw err;
this.sendSocketNotification('DATA', data);
});
}
defaults: {
updateInterval: 30*60*1000 //reads the file every 30 mins
},
start: function(){
this.sendSocketNotification('START', this.config);
},
socketNotificationReceived: function(notification, payload) {
if(notification === 'DATA'){
this.dataFile = payload;
this.updateDom();
}
},
getDom: function(){
var wrapper = document.createElement('div');
if(this.dataFile){
wrapper.innerHTML = this.dataFile;
} else {
wrapper.innerHTML = 'No data';
}
return wrapper;
}