From b09c6afa24975e60c1d4b80f55c6def57b255c7c Mon Sep 17 00:00:00 2001 From: Hagai Cohen Date: Sat, 2 Sep 2017 10:37:40 +0300 Subject: [PATCH] fix: return empty array when find yield no results --- dist/ObservableCursor.js | 4 ++++ dist/ObservableCursor.js.map | 2 +- dist/bundles/index.umd.js | 4 ++++ src/ObservableCursor.ts | 3 +++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/dist/ObservableCursor.js b/dist/ObservableCursor.js index d7334d62..850fa578 100644 --- a/dist/ObservableCursor.js +++ b/dist/ObservableCursor.js @@ -18,6 +18,10 @@ var ObservableCursor = (function (_super) { if (_this._isDataInitinialized) { observer.next(_this._data); } + else if (cursor.count() === 0) { + _this._isDataInitinialized = true; + observer.next(_this._data); + } _this._observers.push(observer); if (!_this._hCursor) { _this._hCursor = _this._observeCursor(cursor); diff --git a/dist/ObservableCursor.js.map b/dist/ObservableCursor.js.map index 098ce7d6..31343767 100644 --- a/dist/ObservableCursor.js.map +++ b/dist/ObservableCursor.js.map @@ -1 +1 @@ -{"version":3,"file":"ObservableCursor.js","sourceRoot":"","sources":["../src/ObservableCursor.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;AAEb,OAAO,EAAC,UAAU,EAAc,OAAO,EAAC,MAAM,MAAM,CAAC;AACrD,OAAO,EAAC,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAC,MAAM,SAAS,CAAC;AAIxD;IAAyC,oCAAe;IAsBtD;;;;OAIG;IACH,0BAAY,MAAuB;QAAnC,YACE,kBAAM,UAAC,QAAyB;YAC9B,EAAE,CAAC,CAAC,KAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC;gBAC9B,QAAQ,CAAC,IAAI,CAAC,KAAI,CAAC,KAAK,CAAC,CAAC;YAC5B,CAAC;YAED,KAAI,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAE/B,EAAE,CAAC,CAAC,CAAC,KAAI,CAAC,QAAQ,CAAC,CAAC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AAI,CAAC,aAAa,EAAE,CAAC;IACvB,CAAC;IAAA,CAAC;IAEF,mCAAQ,GAAR,UAAS,GAAG,EAAE,SAAS,EAAE,OAAO;QAC9B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;QAChC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC;QACnC,IAAI,CAAC,aAAa,EAAE,CAAC;IACvB,CAAC;IAAA,CAAC;IAEF,wCAAa,GAAb;QAAA,iBAMC;QALC,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC;QAEjC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC;YACb,KAAI,CAAC,QAAQ,CAAC,KAAI,CAAC,KAAK,CAAC,CAAC;QAC5B,CAAC,CAAC,CAAC;IACL,CAAC;IAAA,CAAC;IAEF,yCAAc,GAAd,UAAe,MAAuB;QAAtC,iBAQC;QAPC,MAAM,CAAC,KAAK,CAAC,GAAG,CACd,cAAM,OAAA,MAAM,CAAC,OAAO,CAAC;YACnB,OAAO,EAAE,KAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAI,CAAC;YACjC,SAAS,EAAE,KAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAI,CAAC;YACrC,OAAO,EAAE,KAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAI,CAAC;YACjC,SAAS,EAAE,KAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAI,CAAC;SACtC,CAAC,EALI,CAKJ,CAAC,CAAC;IACR,CAAC;IACH,uBAAC;AAAD,CAAC,AApLD,CAAyC,UAAU,GAoLlD"} \ No newline at end of file diff --git a/dist/bundles/index.umd.js b/dist/bundles/index.umd.js index 8bfa2eeb..3ebbdd86 100644 --- a/dist/bundles/index.umd.js +++ b/dist/bundles/index.umd.js @@ -73,6 +73,10 @@ var ObservableCursor = (function (_super) { if (_this._isDataInitinialized) { observer.next(_this._data); } + else if (cursor.count() === 0) { + _this._isDataInitinialized = true; + observer.next(_this._data); + } _this._observers.push(observer); if (!_this._hCursor) { _this._hCursor = _this._observeCursor(cursor); diff --git a/src/ObservableCursor.ts b/src/ObservableCursor.ts index b886dd19..2b233ca9 100644 --- a/src/ObservableCursor.ts +++ b/src/ObservableCursor.ts @@ -36,6 +36,9 @@ export class ObservableCursor extends Observable { super((observer: Subscriber) => { if (this._isDataInitinialized) { observer.next(this._data); + } else if ( cursor.count() === 0 ) { + this._isDataInitinialized = true; + observer.next(this._data); } this._observers.push(observer);