const TASK = { taskType: 'media-sync' }; function registerMediaSyncTask(options) { const backgroundTaskQueue = options && options.backgroundTaskQueue; const uploadSyncService = options && options.uploadSyncService; const runMediaSyncTask = uploadSyncService && uploadSyncService.runMediaSyncTask; if (!backgroundTaskQueue || typeof runMediaSyncTask !== 'function') { throw new Error('registerMediaSyncTask requires the media sync dependencies.'); } // Media sync is just a pass-through to the shared media sync runner. backgroundTaskQueue.setTaskHandler(TASK.taskType, function (task) { return runMediaSyncTask(task && task.payload ? task.payload : task); }); } module.exports = { registerMediaSyncTask };