Structure
Traceable
@propertyWrapper
public struct Traceable<Type>
Add ability to type to have traceable history. property with this propertyWrapper will automatically have version. if propery is set, the set value will enter history.
example
struct User {
@Traceable
var name: String
}
to see more, check Traceable+Tests.swift
Initializers
init(wrappedValue:maxSize:)
public init(wrappedValue: Type, maxSize: Int = 50)
Properties
wrappedValue
public var wrappedValue: Type
Methods
checkout(_:)
public mutating func checkout(_ cursor: Int)
Move cursor to spesific index
Parameters
Name | Type | Description |
---|---|---|
cursor | Int |
index of history |
first(where:)
public func first(where predicate: (Type) throws -> Bool) rethrows -> Type?
Get first item that meet condition
Parameters
Name | Type | Description |
---|---|---|
predicate | (Type) throws -> Bool |
Condition, if true, will return spesific history |
Returns
History that meet given condition
last(where:)
public func last(where predicate: (Type) throws -> Bool) rethrows -> Type?
Get last item that meet condition
Parameters
Name | Type | Description |
---|---|---|
predicate | (Type) throws -> Bool |
Condition, if true, will return spesific history |
Returns
History that meet given condition