All files / src/app/core/utils/paypal/paypal-data-transfer paypal-data-transfer.service.ts

100% Statements 8/8
100% Branches 0/0
100% Functions 3/3
100% Lines 6/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 2732x 32x                       32x   31x     3x         2x      
import { Injectable } from '@angular/core';
import { Observable, Subject } from 'rxjs';
 
interface PaypalOrderData {
  orderId: string;
  paymentInstrumentId: string;
}
 
/**
 * Service to communicate PayPal order data between NgRx effects and PayPal components
 * without triggering Angular change detection.
 */
@Injectable({ providedIn: 'root' })
export class PaypalDataTransferService {
  // Subject that emits PayPal order data when available.
  private paypalOrderData$ = new Subject<PaypalOrderData>();
 
  get paypalOrder$(): Observable<PaypalOrderData> {
    return this.paypalOrderData$.asObservable();
  }
 
  // Emits PayPal order data to all subscribers.
  emitPaypalOrderData(data: PaypalOrderData): void {
    this.paypalOrderData$.next(data);
  }
}