VATextureKit Macro additions.
Triggers a layout update whenever the wrapped variable's value changes.
@Layout var someVariable = false
// expands to
var someVariable = false {
didSet {
setNeedsLayout()
}
}
Triggers a layout update whenever the wrapped variable's value changes only if the new value is distinct from the old value.
@DistinctLayout var someVariable = false
// expands to
var someVariable = false {
didSet {
guard oldValue != someVariable else {
return
}
setNeedsLayout()
}
}
Triggers a layout update whenever the wrapped variable's value changes.
@ScrollLayout var someVariable = false
// expands to
var someVariable = false {
didSet {
scrollNode.setNeedsLayout()
}
}
Triggers a layout update whenever the wrapped variable's value changes only if the new value is distinct from the old value.
@DistinctScrollLayout var someVariable = false
// expands to
var someVariable = false {
didSet {
guard oldValue != someVariable else {
return
}
scrollNode.setNeedsLayout()
}
}
Adds an initializer that substitutes the first case as a default one if it fails to initialize with the given raw value.
@DecodableDefaultCase
enum SomeEnum: String, Codable {
case undefined
case first
}
// expands to
enum SomeEnum: String, Codable {
case undefined
case first
}
extension SomeEnum {
public init(from decoder: Decoder) throws {
self = try SomeEnum(rawValue: decoder.singleValueContainer().decode(RawValue.self)) ?? .undefined
}
}
Volodymyr Andriienko, vandrjios@gmail.com
VATextureKitMacro is available under the MIT license. See the LICENSE file for more info.