2、Operators(操作者)
最新最完整的操作者请查阅官方文档:https://developer.apple.com/documentation/combine/deferred-publisher-operators/
Combine 中的操作者有:
1、映射类的 Mapping elements
- scan
- tryScan
- setFailureType
- map
- tryMap
- flatMap
2、过滤类的 Filtering elements
- compactMap
- tryCompactMap
- replaceEmpty
- filter
- tryFilter
- replaceError
- removeDuplicates
- tryRemoveDuplicates
3、减少类的 Reducing elements
- collect
- reduce
- tryReduce
- ignoreOutput
4、数学计算类的 Mathematic operations on elements
- max
- tryMax
- count
- min
- tryMin
5、校验检测类的 Applying matching criteria to elements
- allSatisfy
- tryAllSatisfy
- contains
- containsWhere
- tryContainsWhere
6、序列索引操作类的 Applying sequence operations to elements
- firstWhere
- tryFirstWhere
- first
- tryLastWhere
- last
- dropWhile
- tryDropWhile
- dropUntilOutput
- prepend
- drop
- prefixUntilOutput
- prefixWhile
- tryPrefixWhile output
7、数据合并类的 Combining elements from multiple publishers
8、错误处理类的 Handling errors
- catch
- tryCatch
- assertNoFailure
- retry
- mapError
9、类型管理类的 Adapting publisher types
- switchToLatest
- eraseToAnyPublisher
10、控制时间类的 Controlling timing
- debounce
- delay
- measureInterval
- throttle
- timeout
11、编码处理类的 Encoding and decoding
12、多个订阅者处理类的 Working with multiple subscribers
13、调试类的 Debugging
- breakpoint 断点 当提供的闭包需要停止调试器中的进程时,它会引发调试器信号
- handleEvents 处理事件
- print 打印打印所有发布事件的日志消息
- breakpointOnError()只有在收到故障时才会引发调试器
操作者有点多,不要被吓到,我们只需要熟悉常用的几个操作者即可。
除非注明,网络人的文章均为原创,转载请以链接形式标明本文地址:http://www.saohen.com/post/185
《【Combine入门】一文搞懂Combine框架里的操作者(Operator)》的网友评论(0)