Context (Product Listing Engine)
Context (Product Listing Engine)
This is for:
DeveloperThe Context
controller injects custom contextual information into the search requests and usage analytics search events sent from a search interface.
Methods
add
Adds (or, if one is already present, replaces) a new context key-value pair.
Parameters
-
contextKey:
string
The context key to add.
-
contextValue:
string | string[]
The context value to add.
remove
Removes a context key from the query.
Parameters
-
key:
string
The context key to remove.
set
Sets the context for the query. This replaces any existing context with the new one.
Parameters
-
context:
Record<string, ContextValue>
The context to set for the query.
subscribe
Adds a callback that’s invoked on state change.
Parameters
-
listener:
() => void
A callback that’s invoked on state change.
Returns Unsubscribe
: A function to remove the listener.
Attributes
state
The state of the Context
controller.
Properties
-
values:
Record<string, ContextValue>
An object holding the context keys and their values.
Initialize
buildContext
Creates a Context
controller instance.
Parameters
-
engine:
ProductListingEngine
The headless engine.
Returns Context
Related Types
Unsubscribe
Call signatures
-
(): void