@groupby/elements-sayt-driver-plugin
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

GroupBy Elements SAYT Driver Plugin

This package contains the GB Elements SAYT (Search-as-you-type) Driver plugin.

Prerequisites

This plugin depends on the following plugins:

  • dom_events
  • sayt
  • search

These plugins must be registered either before or in the same batch as this plugin.

Usage

To use the plugin, simply instantiate it and register it with Core:

const saytDriverPlugin = new SaytDriverPlugin({});
core.register(saytDriverPlugin);

This plugin accepts the following options:

  • productTransformer (optional)
    • A function that accepts a Record object and returns a transformed product. This argument is only necessary if the View Layer is being used. More generally, this function is an opportunity to transform the data into a useable format for your application's front-end.

Events

This plugin listens for and dispatches a number of events. These events are defined in the @groupby/elements-events package.

Received

  • AUTOCOMPLETE_REQUEST: When received, a request to the GroupBy SAYT API is made. An AUTOCOMPLETE_RESPONSE event is dispatched with the results. In case of an error, the AUTOCOMPLETE_ERROR event is dispatched instead.
  • SAYT_PRODUCTS_REQUEST: When received, a search request to the GroupBy API is made to receive products. An SAYT_PRODUCTS_RESPONSE event is dispatched with the results. In case of an error, the SAYT_PRODUCTS_ERROR event is dispatched instead.

Dispatched

  • AUTOCOMPLETE_RESPONSE: Dispatched when a Sayt request has completed. Its payload is the result of the request and includes search autocomplete terms.
  • AUTOCOMPLETE_ERROR: Dispatched when an error has occurred during a Sayt request.
  • SAYT_PRODUCTS_RESPONSE: Dispatched when a search request has completed. Its payload is the result of the request and includes products that may have been transformed.
  • SAYT_PRODUCTS_ERROR: Dispatched when an error has occurred during a search request.
  • BEACON_SEARCH: Dispatched when a search is made sucessfully. Its payload contains the search results and the origin of the action that triggered the search. This can be listened to by built-in or custom trackers.

Dependencies (2)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i @groupby/elements-sayt-driver-plugin

    Weekly Downloads

    1

    Version

    0.2.0

    License

    MIT

    Unpacked Size

    68.4 kB

    Total Files

    25

    Last publish

    Collaborators

    • mykola_bova
    • adruzhkin-gbi
    • anton.shakhlovich
    • artem_konstantinov
    • andzinchenko
    • yberkut-gbi
    • romangbi
    • francoisvongue
    • gleb.bondarenko.gb
    • pavel-shakhlovich
    • jonapgar-groupby
    • kseniya.kondrashevich
    • owengbi
    • yanishgbi
    • jasonwelsh
    • groupby-ops
    • groupby-ci
    • groupbyops
    • daniel-moniz-gbi
    • johanntutorgbi
    • dmytro-kyiashko
    • roman.lis