Class: QueryManager

QueryManager

Provides methods for using IPC queries

Methods

details(productIdnon-null) → {ManagedDetailsQuery}

Get details of a product
Parameters:
Name Type Description
productId string IPC PID of product
Returns:
Type
ManagedDetailsQuery
Examples

Basic usage:

// returns a ManagedDetailsQuery instance
const detailsQuery = queryManager.details(42)
const detailsSub = detailsQuery.out.subscribe((x) => {
  console.log("product details", x);
  // update UI
});
detailsQuery.next();

Unsubscribe from the observables when done:

// when the user navigates to a different page or the component is unmounted
detailsSub.unsubscribe();
detailsQuery.destroy();

filters(categoryIdnon-null) → {ManagedFiltersQuery}

Get filter attributes and values for a category
Parameters:
Name Type Description
categoryId string CT UUID of category
Returns:
Type
ManagedFiltersQuery
Examples

Basic usage:

// returns a ManagedFiltersQuery instance
const filtersQuery = queryManager.filters('c6361e28-370e-4ac0-a720-e64c0a214e07')
const filtersSub = filtersQuery.out.subscribe((x) => {
  console.log("category filters", x);
  // update UI
});
filtersQuery.next();

Unsubscribe from the observables when done:

// when the user navigates to a different page or the component is unmounted
filtersSub.unsubscribe();
filtersQuery.destroy();

products(categoryIdnon-null) → {ManagedProductsQuery}

Get products matching filters for a category
Parameters:
Name Type Description
categoryId string CT UUID of category
Returns:
Type
ManagedProductsQuery
Examples

Basic usage:

// returns a ManagedProductsQuery instance
const productsQuery = queryManager.products('c6361e28-370e-4ac0-a720-e64c0a214e07')
const productsSub = productsQuery.products.subscribe((x) => {
  console.log("products matching filters", x);
  // update UI
});
const totalsSub = productsQuery.totals.subscribe((x) => {
  console.log("total count of products matching filters", x);
  // update UI
});
productsQuery.next({
   pagination: {
     offset: 0,
     limit: 20,
   },
   filters: [
     { attributeId: 11, values: [71, 72] }
   ],
   sort: 0
});

Unsubscribe from the observables when done:

// when the user navigates to a different page or the component is unmounted
productsSub.unsubscribe();
totalsSub.unsubscribe();
productsQuery.destroy();
Search for categories, brands, and products
Returns:
Type
ManagedSearchQuery
Examples

Basic usage:

// returns a ManagedSearchQuery instance
const searchQuery = queryManager.search()
const searchSub = searchQuery.out.subscribe((x) => {
  console.log("search results", x);
  // update UI
});
searchQuery.next('blue jeans');

Unsubscribe from the observables when done:

// when the user navigates to a different page or the component is unmounted
searchSub.unsubscribe();
searchQuery.destroy();

Typeahead search:

// keep calling next() as the user types
searchQuery.next('b');
searchQuery.next('bl');
searchQuery.next('blu');
searchQuery.next('blue');