Skip to content

Commit

Permalink
Avoid .asObservable on each get access to service
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristophHi committed Aug 3, 2023
1 parent 33e80b1 commit 4efb21e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions feature-libs/quote/root/guards/quote-cart.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ export class QuoteCartService {
private quoteCartActive = new ReplaySubject<boolean>(1);
private checkoutAllowed = new ReplaySubject<boolean>(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);
Expand All @@ -28,22 +32,22 @@ export class QuoteCartService {
}

public getQuoteId(): Observable<string> {
return this.quoteId.asObservable();
return this.quoteIdAsObservable;
}

public setQuoteCartActive(quoteCartActive: boolean): void {
this.quoteCartActive.next(quoteCartActive);
}

public isQuoteCartActive(): Observable<boolean> {
return this.quoteCartActive.asObservable();
return this.quoteCartActiveAsObservable;
}

public setCheckoutAllowed(checkoutAllowed: boolean): void {
this.checkoutAllowed.next(checkoutAllowed);
}

public isCheckoutAllowed(): Observable<boolean> {
return this.checkoutAllowed.asObservable();
return this.checkoutAllowedAsObservable;
}
}

0 comments on commit 4efb21e

Please sign in to comment.