Signature
About this widget
Clear Filters lets users clear all filters that are currently active within the given FilterState.
Examples
Instantiate aFilterClearConnector.
Swift
Parameters
The
FilterState that holds your filters.The logic applied to Clear Filters.
Whether we should clear the
specified filters or all filters except them.The group IDs of filters to clear.
All filters will be cleared if unspecified.
The Controller interfacing with a concrete clear filters view.
Low-level API
If you want to fully control theClear Filters components and connect them manually,
use the following components:
FilterClearInteractor. The logic for clearing filters in theFilterState.FilterState. The current state of the filters.FilterClearController. The controller that interfaces with a concrete clear filters view.
Swift
Customizing your view
The controllers provided by default, like theFilterClearButtonController work well when you want to use native UIKit with their default behavior.
If you want to use another component (other than a UIButton) such as a UIView,
a third-party input view,
or you want to introduce some custom behavior to the already provided UIKit component,
you can create your own controller conforming to the FilterClearController protocol.
Protocol
var onClick: ((Facet) -> Void)?:
Closure to call when the clear filters button is clicked.
Example
Swift
SwiftUI
InstantSearch provides theFilterClearObservableController data model,
which is an implementation of the FilterClearController protocol adapted for usage with SwiftUI.
FilterClearObservableController must be connected to the FilterClearConnector or FilterClearInteractor like any other FilterClearController implementation.
The example of the clear filter view using the Button component provided by SwiftUI:
Swift
FilterClearObservableController as a data model.
It provides the clear function to streamline the design process of your custom SwiftUI view.