Skip to content

Commit

Permalink
fix(storage): unsubscribing from the upload progress will not cancel …
Browse files Browse the repository at this point in the history
…and added replay (#2688)

* unsubscribing from upload progress shouldn't cancel the upload, that was undefined behavior IMO
* `shareReplay` the upload, so one could pick back up (say if they had upload progress `| async` on a view somewhere)

Closes #2685
  • Loading branch information
jamesdaniels committed Nov 24, 2020
1 parent 1530112 commit d845cdd
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/storage/observable/fromTask.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Observable } from 'rxjs';
import { shareReplay } from 'rxjs/operators';
import { UploadTask, UploadTaskSnapshot } from '../interfaces';

export function fromTask(task: UploadTask) {
Expand All @@ -13,6 +14,7 @@ export function fromTask(task: UploadTask) {
progress(task.snapshot);
complete();
});
return () => task.cancel();
});
}).pipe(
shareReplay({ bufferSize: 1, refCount: false })
);
}

0 comments on commit d845cdd

Please sign in to comment.