From afa9f362f487f327916d5f390408cd1bbf42b554 Mon Sep 17 00:00:00 2001 From: Dominique Quatravaux Date: Thu, 7 Nov 2019 16:15:27 +0100 Subject: [PATCH] ObservableCursor: _.clone collection lists before passing them to callbacks Fixes #244 --- src/ObservableCursor.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ObservableCursor.ts b/src/ObservableCursor.ts index e47518bd..afbc5c4a 100644 --- a/src/ObservableCursor.ts +++ b/src/ObservableCursor.ts @@ -41,10 +41,10 @@ export class ObservableCursor extends Observable { Meteor.setTimeout(() => { if (this._isDataInitinialized) { - observer.next(this._data); + observer.next(_.clone(this._data)); } else if (cursor.count() === 0) { this._isDataInitinialized = true; - observer.next(this._data); + observer.next(_.clone(this._data)); } }, 0); @@ -144,7 +144,7 @@ export class ObservableCursor extends Observable { this._countObserver.next(this._data.length); this._observers.forEach(observer => { - observer.next(data); + observer.next(_.clone(data)); }); } @@ -173,7 +173,7 @@ export class ObservableCursor extends Observable { this._isDataInitinialized = true; this._zone.run(() => { - this._runNext(this._data); + this._runNext(this._data); }); }