本文整理匯總了TypeScript中algoliasearch-helper類的典型用法代碼示例。如果您正苦於以下問題:TypeScript algoliasearch-helper類的具體用法?TypeScript algoliasearch-helper怎麽用?TypeScript algoliasearch-helper使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了algoliasearch-helper類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: algoliasearch
import * as algoliasearch from 'algoliasearch';
import * as algoliasearchHelper from 'algoliasearch-helper';
// tslint:disable-next-line:no-duplicate-imports
import { SearchResults, SearchParameters } from 'algoliasearch-helper';
// https://community.algolia.com/algoliasearch-helper-js/reference.html#module:algoliasearchHelper
const client = algoliasearch('latency', '6be0576ff61c053d5f9a3225e2a90f76');
const helper = algoliasearchHelper(client, 'bestbuy', {
facets: ['shipping'],
disjunctiveFacets: ['category']
});
helper.on('result', (result) => {
console.log(result);
});
helper.toggleRefine('Movies & TV Shows')
.toggleRefine('Free shipping')
.search();
const updateTheResult = (results: SearchResults, state: SearchParameters) => {
console.log(results, state);
};
helper.on('result', updateTheResult);
helper.once('result', updateTheResult);
helper.removeListener('result', updateTheResult);
helper.removeAllListeners('result');
() => {
// Changing the number of records returned per page to 1
// This example uses the callback API
const state = helper.searchOnce({hitsPerPage: 1},
示例2: algoliasearchHelper
() => {
const helper2 = algoliasearchHelper(client, 'test', {
disjunctiveFacets: ['nameOfTheAttribute']
});
};