'use strict'; const configure = (configuration, service) => { const fetchIt = (storage) => { // Setup fetching in web workers if (window.Worker) { const workerBaseURL = window.informationProjectorConfig.get('workerBaseURL'); const fetchWorkerCode = workerBaseURL + "/generic_fetch_worker.js"; // Schedule fetch worker const scheduleWorker = new Worker(fetchWorkerCode); const scheduleType = 'Schedule'; const scheduleURL = window.informationProjectorConfig.get('scheduleURL'); const scheduleFetchInterval = window.informationProjectorConfig.get('scheduleFetchInterval'); // Configure schedule worker scheduleWorker.postMessage({fetchType: scheduleType, fetchURL: scheduleURL, fetchInterval: scheduleFetchInterval }); // Obtain schedule results and call back scheduleWorker.onmessage = function(e) { if (e.data.msgType === scheduleType) { let jsonData = e.data.json; console.info("Got it"); console.info(jsonData); let scheduleData = service.process_data(jsonData); //let scheduleData = e.data.json; console.info(scheduleData); storage.scheduleData = scheduleData; console.info("Got it"); console.info(storage); // update_screen(); } }; // Add more workers here } else { console.error("Your browser doesn't support web workers."); } }; return fetchIt; }; export { configure };