GitHub

DaffCategoryFacade

import { DaffCategoryFacade } from '@daffodil/category/state'

A facade for interacting with the category state. This facade exposes many parts of the state for easy access and allows dispatching of actions.

@Injectable()
class DaffCategoryFacade<<V extends DaffGenericCategory<V> = DaffCategory, W extends DaffProduct = DaffProduct>>  implements DaffCategoryFacadeInterface<V, W> {
  category$: Observable<V>
  loadingState$: Observable<DaffCategoryReducerState['daffState']>
  loading$: Observable<boolean>
  mutating$: Observable<boolean>
  resolving$: Observable<boolean>
  products$: Observable<W[]>
  errors$: Observable<DaffStateError[]>
  hasErrors$: Observable<boolean>
  isCategoryEmpty$: Observable<boolean>

  getCategoryById(id: V["id"]): Observable<V>
  getProductsByCategory(categoryId: V["id"]): Observable<W[]>
  getTotalProductsByCategory(categoryId: V["id"]): Observable<number>
  dispatch(action: Action<string>): void
}

Properties

category$
Observable<V>
Default
Description

The currently selected category.

loadingState$
Observable<DaffCategoryReducerState['daffState']>
Default
Description
loading$
Observable<boolean>
Default
Description
mutating$
Observable<boolean>
Default
Description
resolving$
Observable<boolean>
Default
Description
products$
Observable<W[]>
Default
Description

Products of the current category.

errors$
Observable<DaffStateError[]>
Default
Description
hasErrors$
Observable<boolean>
Default
Description
isCategoryEmpty$
Observable<boolean>
Default
Description

Is the category page empty of products.

() Methods

getCategoryById
Observable<V>

Get a category by the provided Id.

@param id

Parameters
Parameterid: V["id"]
Description
getProductsByCategory
Observable<W[]>

Get products by a category Id.

@param categoryId

Parameters
ParametercategoryId: V["id"]
Description
getTotalProductsByCategory
Observable<number>

Get products by a category Id.

@param categoryId

Parameters
ParametercategoryId: V["id"]
Description
dispatch
void

Dispatches the given action.

Parameters
Parameteraction: Action
Description

action to dispatch.