Parameter
A type that monitors the state of its wrapped value to reevaluate any dependent tip rules when the value changes.
Declaration
struct Parameter<Value> where Value : Decodable, Value : Encodable, Value : SendableOverview
You create a parameter by wrapping a conforming type with the @Parameter macro. An id is generated based on the parameter’s enclosing instance and the name of the property it is wrapping.
Tips must be configured using configure(_:) before a parameter’s value will be updated.
Pair parameters with the tip properties you want to monitor.
For example, to track whether someone has previously used a feature in your app, define a property wrapper, along with the parameter with the value you want to track in your tip as follows:
struct LandmarksUser {
// Define the user interaction you want to use for a display rule.
@Parameter
static var hasFavoritedLandmark: Bool = false
}Then construct a rule for your tip based on that parameter:
struct FavoriteLandmarkTip: Tip {
var rules: [Rule] {
// Tip will only display when `hasFavoritedLandmark` is false.
#Rule(LandmarksUser.hasFavoritedLandmark) {
$0 == false
}
}
}