alferov/angular-file-saver

[Feature Request] Broadcast saveAs() result

aaronmallen opened this issue · 0 comments

I'd like to see some form of broadcast, or perhaps callback firing depending on FileSaver.saveAs completion.

i.e.

// with callback support.
function resultFN(e) {
  console.log('File Saved!');
  return e;
}

var data = new Blob([text], { type: 'text/plain;charset=utf-8' });
FileSaver.saveAs(data, 'text.txt', resultFN);

// or on broadcast
$rootScope.$on('FileSaverSuccess', function (e, opts) {
   console.log('File Saved!');
   return e;
});

// or on promise resolution
var data = new Blob([text], { type: 'text/plain;charset=utf-8' });
FileSaver.saveAs(data, 'text.txt').then(function (result) {
  console.log('File Saved!');
  return result;
});