DelayedValue
open class DelayedValue<T>
Simple abstraction that simplifies working with values that needs some time to be fetched. Kind of promise. Good to use in view models to simplify view configuration.
-
Undocumented
Declaration
Swift
public typealias GetValue = (_ completion: @escaping UseValue) -> ()
-
Undocumented
Declaration
Swift
public typealias UseValue = (_ value: T) -> ()
-
Returns value if it’s available or nil.
Declaration
Swift
private(set) public var value: T? { get }
-
Allows to init DelayedValue without getValue closure in case it might be needed to set it later.
Declaration
Swift
public init()
-
Init DelayedValue with getValue closure
Declaration
Swift
public init(getValue: @escaping GetValue)
-
Allows to set getValue closure. It’ll be executed right after and call onValueAvaliable when available.
Declaration
Swift
public func setGetValueClosure(_ getValue: @escaping GetValue)
-
Sets onValueAvailable closure that will be called when value available or immediately if value already available.
Declaration
Swift
public func onValueAvailable(_ onValueAvaliable: @escaping UseValue)