Skip to content

Commit 9b28d84

Browse files
committed
fix(FirebaseList): unregister firebase listeners on unsubscription
1 parent 4dbcb78 commit 9b28d84

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/providers/firebase_list.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,15 @@ describe('FirebaseList', () => {
150150
nextSpy.calls.mostRecent().args[0].map((v:any) => v.val())
151151
).toEqual([2,1]);
152152
});
153+
154+
155+
it('should call off on all events when disposed', () => {
156+
var firebaseSpy = spyOn(Firebase.prototype, 'off');
157+
var subscribed = FirebaseListFactory('ws://test.firebaseio.com:5000').subscribe();
158+
expect(firebaseSpy).not.toHaveBeenCalled();
159+
subscribed.unsubscribe();
160+
expect(firebaseSpy).toHaveBeenCalled();
161+
});
153162
});
154163

155164

src/providers/firebase_list.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ export function FirebaseListFactory (absoluteUrl:string): FirebaseObservable<any
3434
// This also manages when the only change is prevKey change
3535
obs.next(arr = onChildChanged(arr, child, prevKey));
3636
});
37+
38+
return ref.off;
3739
}, ref);
3840
}
3941

0 commit comments

Comments
 (0)