Signature
Explore example code
Browse the Filter Numeric Comparison example code on GitHub.
About this widget
Filter Numeric Comparison is a view to filter on a numeric value using a comparison operator.Examples
Instantiate aFilterComparisonConnector and launch an initial search on its searcher.
Swift
Low-level API
If you want to fully control the Filter Numeric Comparison components and connect them manually, use the following components:Searcher. TheSearcherthat handles your searches.FilterState. The current state of the filters.NumberInteractor<T>. The logic applied to the numeric value.NumberController. The view controller that renders the numeric value.
Swift
SwiftUI
InstantSearch provides theNumberObservableController as a state model,
which is an implementation of the NumberController interface.
You need to connect NumberObservableController to the FilterComparisonConnector or NumberInteractor like any other NumberController implementation.
Swift
NumberObservableController as a data model.
It provides value and bounds properties to streamline the design process of your custom SwiftUI view.
Parameters
HitsSearcher
required
The Searcher that handles your searches
FilterState
required
The
FilterState that holds filters.Attribute
required
The attribute to filter on.
Filter.Numeric.Operator
required
The comparison operator to apply.
Number: Comparable & DoubleRepresentable
default: nil
The initial numeric value to filter on.
ClosedRange<Number>?
default: nil
The optional bounds limiting the max and the min value of the number.
RefinementOperator
required
default: .and
Whether the filter is added to a conjuncitve(
and) or a disjuncitve (or) group in the filter state.String?
default: nil
Filter group name in the filter state.
If not specified, the attribute value is used as the group name.
Controller
NumberController
required
Controller interfacing with a concrete number view.
Swift