Signature
About this widget
TheQueryRuleCustomData
widget displays custom data from Rules.
You can use this widget to display banners or recommendations returned by rules when they match search parameters.
Examples
Instantiate aQueryRuleCustomDataConnector
and launch an initial search on its Searcher
, triggering a Rule that returns custom data.
Android view
Kotlin
Compose UI
InstantSearch provides theQueryRuleCustomDataState
as a state model,
which is an implementation of the QueryRuleCustomDataPresenter
interface.
Kotlin
Parameters
Initial model value.
The Presenter defining how a model appears.
Kotlin
Low-level API
If you want to fully control theQueryRuleCustomData
components and connect them manually,
you can use the following components:
Searcher
. TheSearcher
that handles your searches.QueryRuleCustomDataViewModel
. The component encapsulating the logic applied to the custom model.QueryRuleCustomDataPresenter
. Defines the way we want to interact with a model.
Kotlin
Serialization
You must provide aDeserializationStrategy<T>
implementation to deserialize your custom models.
An easy way to achieve this is to annotate your custom model class with @Serialization
.
The Kotlin serialization compiler plugin then automatically generates an implementation for you,
accessible using the .serializer()
function on the class’s companion object.
Example
Suppose your custom JSON data contains a banner URL that can be decoded to the following structure:Kotlin
Kotlin
Kotlin