實例方法
min()
在完成後發布從上遊發布者收到的最小值。
聲明
func min() -> Publishers.Comparison<Self>
當
Output
符合 Comparable
時可用。返回值
在上遊發布者完成後發布從上遊發布者收到的最小值的發布者。
詳述
使用Publisher/min(by:)
查找來自上遊發布者的元素流中的最小值。
在下麵的示例中,Publisher/min(by:)
運算符在發布者完成時發出一個值,該值是從上遊接收到的值的最小值,即 -1
。
let numbers = [-1, 0, 10, 5]
numbers.publisher
.min()
.sink { print("\($0)") }
// Prints: "-1"
在此發布者收到超過 0 個項目的請求後,它會向其上遊發布者請求無限個項目。
可用版本
iOS 13.0+, iPadOS 13.0+, macOS 10.15+, Mac Catalyst 13.0+, tvOS 13.0+, watchOS 6.0+
相關用法
- Swift Result.Publisher merge(with:_:_:)用法及代碼示例
- Swift Result.Publisher merge(with:_:_:_:_:_:_:)用法及代碼示例
- Swift Result.Publisher map(_:_:_:)用法及代碼示例
- Swift Result.Publisher merge(with:_:)用法及代碼示例
- Swift Result.Publisher map(_:)用法及代碼示例
- Swift Result.Publisher multicast(_:)用法及代碼示例
- Swift Result.Publisher merge(with:_:_:_:_:_:)用法及代碼示例
- Swift Result.Publisher multicast(subject:)用法及代碼示例
- Swift Result.Publisher merge(with:_:_:_:_:)用法及代碼示例
- Swift Result.Publisher max()用法及代碼示例
- Swift Result.Publisher merge(with:_:_:_:)用法及代碼示例
- Swift Result.Publisher measureInterval(using:options:)用法及代碼示例
- Swift Result.Publisher map(_:_:)用法及代碼示例
- Swift Result.Publisher mapError(_:)用法及代碼示例
- Swift Result.Publisher makeConnectable()用法及代碼示例
- Swift Result.Publisher zip(_:_:_:)用法及代碼示例
- Swift Result.Publisher tryLast(where:)用法及代碼示例
- Swift Result.Publisher sink(receiveCompletion:receiveValue:)用法及代碼示例
- Swift Result.Publisher tryCompactMap(_:)用法及代碼示例
- Swift Result.Publisher print(_:to:)用法及代碼示例
- Swift Result.Publisher sink(receiveValue:)用法及代碼示例
- Swift Result.Publisher eraseToAnyPublisher()用法及代碼示例
- Swift Result.Publisher setFailureType(to:)用法及代碼示例
- Swift Result.Publisher first(where:)用法及代碼示例
- Swift Result.Publisher output(at:)用法及代碼示例
注:本文由純淨天空篩選整理自apple.com大神的英文原創作品 Result.Publisher min()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。