Skip to content

Commit

Permalink
feat: use RxJS lettable operators
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidRouyer authored and jkuri committed Jan 31, 2018
1 parent d5c4d3e commit 806e88c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/ngx-uploader/classes/ngx-uploader.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { EventEmitter } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { Subject } from 'rxjs/Subject';
import { Subscription } from 'rxjs/Subscription';
import 'rxjs/add/operator/mergeMap';
import { mergeMap } from 'rxjs/operators/mergeMap';
import { UploadFile, UploadOutput, UploadInput, UploadStatus, BlobFile } from './interfaces';

export function humanizeBytes(bytes: number): string {
Expand All @@ -26,13 +26,15 @@ export class NgUploaderService {

constructor(concurrency: number = Number.POSITIVE_INFINITY, contentTypes: string[] = ['*']) {
this.queue = [];
this.serviceEvents = new EventEmitter<any>();
this.serviceEvents = new EventEmitter<UploadOutput>();
this.uploadScheduler = new Subject();
this.subs = [];
this.contentTypes = contentTypes;

this.uploadScheduler
.mergeMap(upload => this.startUpload(upload), concurrency)
.pipe(
mergeMap(upload => this.startUpload(upload), concurrency)
)
.subscribe(uploadOutput => this.serviceEvents.emit(uploadOutput));
}

Expand Down

0 comments on commit 806e88c

Please sign in to comment.