New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add meteor http events #3266

Closed
smeijer opened this Issue Dec 9, 2014 · 2 comments

Comments

Projects
None yet
3 participants
@smeijer

smeijer commented Dec 9, 2014

Should be great if we could bind to events from the xhr stream. Like for example 'onprogress' for monitoring progress of a file upload. This is currently the only thing preventing me from using Meteor.http instead of other xhr libraries.


Example usage:

var _reactiveDict = new ReactiveDict({
  progress: 0 
});

var result = HTTP.call('put', 'http://external-service...', {
  headers: {
     'X-Auth-Token': 'myToken'
  },
  events: {
    'progress': function(p) { 
      _reactiveDict.set('progress', p); 
    }
  },
  content: uploadedFile
});

Tracker.autorun(function() {
   var uploadProgress = _reactiveDict.get('progress');
   console.log('uploading file: ' + uploadProgress + '%');
});
@glasser

This comment has been minimized.

Member

glasser commented Jan 12, 2015

Thanks for the feature request! You might be interested in reading our feature request guidelines.

@robertpitt

This comment has been minimized.

robertpitt commented May 20, 2015

This could be solved by t he referenced PR above.

var result = HTTP.call('put', 'http://external-service...', {
  headers: {
     'X-Auth-Token': 'myToken'
  },

  beforeSend: function(xhr){
    xhr.onprogress = function(){
      if (e.lengthComputable) {
         _reactiveDict.set('progress', (e.loaded / e.total) * 100); 
      }
    }
  },
  content: uploadedFile
});

@glasser glasser closed this in 43cd920 Jun 16, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment