Skip to content
This repository was archived by the owner on Nov 30, 2022. It is now read-only.

Commit 249c262

Browse files
committed
feat(storage): address Ben's comments
1 parent 30d373e commit 249c262

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

src/storage/observable/fromTask.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
import { storage } from 'firebase/app';
2-
import 'firebase/storage';
32
import { Observable } from 'rxjs/Observable';
43

54
export function fromTask(task: storage.UploadTask) {
65
return new Observable<storage.UploadTaskSnapshot | undefined>(subscriber => {
7-
task.on('state_changed',
8-
(snap: storage.UploadTaskSnapshot) => subscriber.next(snap),
9-
e => subscriber.error(e),
10-
() => subscriber.complete()
11-
);
12-
return { unsubscribe: task.cancel };
6+
const progress = (snap: storage.UploadTaskSnapshot) => subscriber.next(snap);
7+
const error = e => subscriber.error(e);
8+
const complete = () => subscriber.complete();
9+
task.on('state_changed', progress, error, complete);
10+
return () => task.cancel();
1311
});
1412
}

src/storage/storage.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ describe('AngularFireStorage', () => {
5858
const task = ref.put(blob);
5959
const url$ = task.downloadURL();
6060
url$.subscribe(
61-
url => { console.log(url); expect(url).toBeDefined(); },
61+
url => { expect(url).toBeDefined(); },
6262
e => { done.fail(); },
6363
() => { ref.delete().subscribe(done, done.fail); }
6464
);

src/storage/task.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { storage } from 'firebase/app';
22
import { fromTask } from './observable/fromTask';
33
import { Observable } from 'rxjs/Observable';
4-
import { map, filter, shareReplay } from 'rxjs/operators';
4+
import { map, filter } from 'rxjs/operators';
55

66
export interface AngularFireUploadTask {
77
snapshotChanges(): Observable<storage.UploadTaskSnapshot | undefined>;
@@ -15,7 +15,7 @@ export interface AngularFireUploadTask {
1515
}
1616

1717
export function createUploadTask(task: storage.UploadTask): AngularFireUploadTask {
18-
const inner$ = fromTask(task).pipe(shareReplay());
18+
const inner$ = fromTask(task);
1919
return {
2020
pause() { return task.pause(); },
2121
cancel() { return task.cancel(); },

0 commit comments

Comments
 (0)