GitHub

DaffProductFacadeInterface

import { DaffProductFacadeInterface } from '@daffodil/product/state'

A facade for getting state about a particular product.

interface DaffProductFacadeInterface<T extends DaffProduct = DaffProduct> {
  getProduct(id: T["id"]): Observable<T>
  getPrice(id: T["id"]): Observable<number>
  hasDiscount(id: T["id"]): Observable<boolean>
  getDiscountAmount(id: T["id"]): Observable<number>
  getDiscountedPrice(id: T["id"]): Observable<number>
  getDiscountPercent(id: T["id"]): Observable<number>
  isOutOfStock(id: T["id"]): Observable<boolean>
}

() Methods

getProduct
Observable<T>

Get a product.

Parameters
Parameterid: T["id"]
Description

a product id

getPrice
Observable<number>

Get the original price for a product.

Parameters
Parameterid: T["id"]
Description

a product id

hasDiscount
Observable<boolean>

Whether a particular product has a discount.

Parameters
Parameterid: T["id"]
Description

a product id

getDiscountAmount
Observable<number>

Get the discount amount of a product.

Parameters
Parameterid: T["id"]
Description

a product id

getDiscountedPrice
Observable<number>

Get the discounted price for a product.

Parameters
Parameterid: T["id"]
Description

a product id

getDiscountPercent
Observable<number>

Get the discount percent of a product.

Parameters
Parameterid: T["id"]
Description

a product id

isOutOfStock
Observable<boolean>

Whether a product is out of stock.

Parameters
Parameterid: T["id"]
Description

a product id