小编kum*_*one的帖子

iOS13 的组合流在使用调度程序的操作员之后不流动

iOS13 的发布者组合流似乎不会在使用调度程序的操作员之后流动。

这是我的代码:

import Foundation
import Combine

struct MyPublisher: Publisher {
    typealias Output = Int
    typealias Failure = Error

    func receive<S>(subscriber: S) where S : Subscriber,
        Failure == S.Failure,
        Output == S.Input {
            subscriber.receive(1)
            print("called 1")
            subscriber.receive(2)
            print("called 2")
            subscriber.receive(completion: .finished)
            print("called finish")
    }
}

MyPublisher()
//    .receive(on: RunLoop.main) // If this line removed, it will be fine.
//    .throttle(for: .milliseconds(1000), scheduler: RunLoop.main, latest: false)) // If this line removed, it will be fine.
//    .debounce(for: .milliseconds(1000), scheduler: RunLoop.main)) // …
Run Code Online (Sandbox Code Playgroud)

swift ios13 combine

6
推荐指数
1
解决办法
9443
查看次数

标签 统计

combine ×1

ios13 ×1

swift ×1