Skip to content

Commit

Permalink
feat(concurrency): fix concurrency
Browse files Browse the repository at this point in the history
  • Loading branch information
jkuri committed Aug 6, 2017
1 parent ce693cf commit ca746de
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/components/app-home/app-home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class AppHomeComponent {

constructor() {
this.formData = {
concurrency: 0,
concurrency: 1,
autoUpload: false,
verbose: true
};
Expand Down
12 changes: 8 additions & 4 deletions src/ngx-uploader/classes/ngx-uploader.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import { EventEmitter } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { Subscription } from 'rxjs/Subscription';
import { Subscriber } from 'rxjs/Subscriber';
import 'rxjs/add/observable/of';
import 'rxjs/add/observable/from';
import 'rxjs/add/operator/mergeAll';
import 'rxjs/add/operator/mergeMap';
import 'rxjs/add/operator/map';

export enum UploadStatus {
Queue,
Expand Down Expand Up @@ -133,9 +135,11 @@ export class NgUploaderService {
return;
}

Observable.from(files.map(file => file.sub = this.uploadFile(file, event)))
.mergeAll(concurrency)
.subscribe((data: UploadOutput) => this.serviceEvents.emit(data));
Observable.of(...files)
.mergeMap(file => {
return this.uploadFile(file, event);
}, concurrency)
.subscribe(data => this.serviceEvents.emit(data));
break;
case 'cancel':
const id = event.id || null;
Expand Down

0 comments on commit ca746de

Please sign in to comment.