AllValues<T>
// 2020.10.15:
import SwiftUI
// 📦 AllValues<T>
public struct AllValues<T>: PreferenceKey {
// ⭐️ 收集的資料放在 [T] 裡面
public typealias Value = [T]
// ⭐️ 初始值:空陣列
public static var defaultValue: Value { Value() }
// ⭐️ 加入新資料的方法:[v1, v2, ...] + [vn]
public static func reduce(value: inout Value, nextValue: () -> Value) {
value += nextValue() // nextValue() == [vn]
}
}
Last updated
Was this helpful?