State
editState
editState can be divided up into a few different types.
- Request State - State that is used as parameters on Search API calls.
- Response State - State that represents a response from a Search API call.
- Application State - The general state.
Request State and Response State will often have similar values. For instance, searchTerm
and resultSearchTerm
.
searchTerm
is the current search term in the UI, and resultSearchTerm
is the term associated with the current
results
. This can be relevant in the UI, where you might not want the search term on the page to change until AFTER
a response is received, so you’d use the resultSearchTerm
state.
Request State
editState that is used as parameters on Search API calls.
Request state can be set by:
-
Using actions, like
setSearchTerm
-
The
initialState
option. -
The URL query string, if
trackUrlState
is enabled.
option | Description |
---|---|
|
Current page number |
|
Array of filters. See Filters section. |
|
|
|
Search terms to search for |
|
List of fields and directions to sort on |
Response State
editState that represents a response from a Search API call.
It is not directly update-able.
It is updated indirectly by invoking an action which results in a new API request.
field | description |
---|---|
|
An array of results items fetched for an autocomplete dropdown. |
|
A unique ID for the current autocompleted search results. |
|
A keyed object of query suggestions. It’s keyed by type since multiple types of query suggestions can be set here. |
|
A unique ID for the current autocompleted suggestion results. |
|
Will be populated if |
|
The response object received from the API |
|
A unique ID for the current search results. |
|
An array of result items. |
|
As opposed the the |
|
Total number of results found for the current query. |
Application State
editApplication state is the general application state.
field | description |
---|---|
|
Error message, if an error was thrown. |
|
Whether or not a search is currently being performed. |
|
Has any query been performed since this driver was created? Can be useful for displaying initial states in the UI. |