From 4efb21e641eadcd90e041b0955315ff25a854a08 Mon Sep 17 00:00:00 2001 From: Christoph Hinssen Date: Thu, 3 Aug 2023 15:57:58 +0200 Subject: [PATCH] Avoid .asObservable on each get access to service --- feature-libs/quote/root/guards/quote-cart.service.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/feature-libs/quote/root/guards/quote-cart.service.ts b/feature-libs/quote/root/guards/quote-cart.service.ts index 79b19b0553e..fbaeca84d56 100644 --- a/feature-libs/quote/root/guards/quote-cart.service.ts +++ b/feature-libs/quote/root/guards/quote-cart.service.ts @@ -17,6 +17,10 @@ export class QuoteCartService { private quoteCartActive = new ReplaySubject(1); private checkoutAllowed = new ReplaySubject(1); + private quoteIdAsObservable = this.quoteId.asObservable(); + private quoteCartActiveAsObservable = this.quoteCartActive.asObservable(); + private checkoutAllowedAsObservable = this.checkoutAllowed.asObservable(); + constructor() { this.quoteCartActive.next(false); this.checkoutAllowed.next(false); @@ -28,7 +32,7 @@ export class QuoteCartService { } public getQuoteId(): Observable { - return this.quoteId.asObservable(); + return this.quoteIdAsObservable; } public setQuoteCartActive(quoteCartActive: boolean): void { @@ -36,7 +40,7 @@ export class QuoteCartService { } public isQuoteCartActive(): Observable { - return this.quoteCartActive.asObservable(); + return this.quoteCartActiveAsObservable; } public setCheckoutAllowed(checkoutAllowed: boolean): void { @@ -44,6 +48,6 @@ export class QuoteCartService { } public isCheckoutAllowed(): Observable { - return this.checkoutAllowed.asObservable(); + return this.checkoutAllowedAsObservable; } }