Skip to content

Commit

Permalink
Added event with return of request
Browse files Browse the repository at this point in the history
  • Loading branch information
David Martins committed Oct 4, 2017
1 parent 5df3c5f commit 5357a24
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/file-upload/file-uploader.class.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { EventEmitter } from '@angular/core';
import { FileLikeObject } from './file-like-object.class';
import { FileItem } from './file-item.class';
import { FileType } from './file-type.class';
Expand Down Expand Up @@ -43,6 +44,7 @@ export class FileUploader {
public _nextIndex:number = 0;
public autoUpload:any;
public authTokenHeader: string;
public response: EventEmitter<any>;

public options:FileUploaderOptions = {
autoUpload: false,
Expand All @@ -56,6 +58,7 @@ export class FileUploader {

public constructor(options:FileUploaderOptions) {
this.setOptions(options);
this.response = new EventEmitter<any>();
}

public setOptions(options:FileUploaderOptions):void {
Expand Down Expand Up @@ -358,6 +361,11 @@ export class FileUploader {
xhr.setRequestHeader(this.authTokenHeader, this.authToken);
}
xhr.send(sendable);
xhr.onreadystatechange = function() {
if (xhr.readyState == XMLHttpRequest.DONE) {
this.response.emit(xhr.responseText)
}
}
this._render();
}

Expand Down

0 comments on commit 5357a24

Please sign in to comment.