From abf6ff02247c5a76ae7925ea8e34a52d1005e35a Mon Sep 17 00:00:00 2001 From: GrandSchtroumpf Date: Wed, 21 Jul 2021 16:10:27 +0200 Subject: [PATCH] keep memory of last value seen --- projects/akita-ng-fire/src/lib/utils/share-delay.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/projects/akita-ng-fire/src/lib/utils/share-delay.ts b/projects/akita-ng-fire/src/lib/utils/share-delay.ts index d4497b7..db9745d 100644 --- a/projects/akita-ng-fire/src/lib/utils/share-delay.ts +++ b/projects/akita-ng-fire/src/lib/utils/share-delay.ts @@ -19,16 +19,19 @@ export function shareWithDelay(delay: number = 100): MonoTypeOperatorFunction let refCount = 0; let hasError = false; let isComplete = false; + let lastValue: T; function operation(this: Subscriber, source: Observable) { refCount++; let innerSub: Subscription | undefined; if (!subject || hasError) { hasError = false; subject = new ReplaySubject(1, Infinity); + if (lastValue) subject.next(lastValue); innerSub = subject.subscribe(this); subscription = source.subscribe({ next(value) { subject?.next(value); + lastValue = value; }, error(err) { hasError = true;