本文整理汇总了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']
});
};