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
}
Observable<V>
Default | – |
---|---|
Description | The currently selected category. |
Observable<DaffCategoryReducerState['daffState']>
Default | – |
---|---|
Description |
Observable<boolean>
Default | – |
---|---|
Description |
Observable<boolean>
Default | – |
---|---|
Description |
Observable<boolean>
Default | – |
---|---|
Description |
Observable<W[]>
Default | – |
---|---|
Description | Products of the current category. |
Observable<DaffStateError[]>
Default | – |
---|---|
Description |
Observable<boolean>
Default | – |
---|---|
Description |
Observable<boolean>
Default | – |
---|---|
Description | Is the category page empty of products. |
Observable<V>
Get a category by the provided Id.
@param id
Parameter | id: V["id"] |
---|---|
Description |
Observable<W[]>
Get products by a category Id.
@param categoryId
Parameter | categoryId: V["id"] |
---|---|
Description |
Observable<number>
Get products by a category Id.
@param categoryId
Parameter | categoryId: V["id"] |
---|---|
Description |
void
Dispatches the given action.
Parameter | action: Action |
---|---|
Description | action to dispatch. |