An incredibly very simple fetch assets loader that load every file as a blob and return a media element ( image / video / sound / json )
varfetchLoader=require('fetch-loader')this.files=[]// { // name: 'image', => name of the media // url : ROOTPATH + IMAGE_PATH + 'image.jpg', => url of the media // data: {description: "red image"} => additional data you want to be associated with the loaded media// }this.files.push({name: 'videoxsd',url : ROOTPATH+VIDEO_PATH+'videoxsd.mp4'})this.files.push({name: 'image',url : ROOTPATH+IMAGE_PATH+'image.jpg',data: {description: "red image"})this.files.push({name: 'sound',url : ROOTPATH+SOUND_PATH+'sound.mp3'})this.files.push({name: 'myjson',url : ROOTPATH+JSON_PATH+'data.json'})varfetchLoaderManager=newfetchLoader()// file event fire everytime a file is loadedfetchLoaderManager.on('file',onFile)// complete event fire when everything is loadedfetchLoaderManager.on('complete',onComplete)// fetchLoaderManager.load options : // parallel : limit of the unsync fetch loading// headreq : determine if the loader first process a head request ( true progression values ) fetchLoaderManager.load(this.files,{parallel: 8,headreq: true})// kill eventsfetchLoaderManager.off('file')fetchLoaderManager.off('complete')