Tweak
@propertyWrapper
public class Tweak<Value> : AnyTweak, TweakType where Value : Storable
extension Tweak: AnyTradableTweak where Value: TradedTweakable
The base class of tweak.
Use Tweak
as a property wrapper.
A Tweak
object represents a tweak in the UI.
-
Declaration
Swift
public let name: String
-
Declaration
Swift
public weak var section: TweakSection? { get set }
-
Declaration
Swift
public let info: TweakInfo
-
Declaration
Swift
public var currentValue: Storable { get }
-
Declaration
Swift
public var primaryViewReuseID: String { get }
-
Declaration
Swift
public var primaryView: TweakPrimaryView { get }
-
Declaration
Swift
public var hasSecondaryView: Bool { get }
-
Declaration
Swift
public var secondaryView: TweakSecondaryView? { get }
-
The final value of the tweak.
Note
The final value is the transformed (by value transformers of the tweak) value of current value.Declaration
Swift
public final var wrappedValue: Value { get }
-
The tweak itself.
Declaration
Swift
public final var projectedValue: Tweak<Value> { get }
-
A transformer that transforms tweak value.
Declaration
Swift
public typealias ValueTransformer = (Value) -> Value
-
Adds a value transformer to the end of the transformer chain.
Transformers are applied one by one in the chain.
Declaration
Swift
@discardableResult public func addValueTransformer(_ transformer: @escaping ValueTransformer) -> Self
Parameters
transformer
The transformer.
Return Value
The current tweak.
-
Declaration
Swift
func register(in context: TweakContext)
-
Stops observing the value change of the tweak.
Declaration
Swift
func stopObservingValueChange(token: NotifyToken? = nil)
Parameters
token
A token that acts as the observation. Pass nil will stop all the observations of the tweak.
-
Starts observing the value change of the tweak.
Note
Hold the token strongly or the observation will stop.
Declaration
Swift
func startObservingValueChange(_ handler: @escaping (Value, Value, Bool) -> Void) -> NotifyToken
Parameters
handler
A block that TweaKit calls after value change. The block takes the following parameter:
Return Value
A token that acts as the observation.
-
Declaration
Swift
public func rawData(from value: TweakTradeValue) -> Result<Data, TweakError>
-
Declaration
Swift
public func tradeValue() -> TweakTradeValue