Quantcast
Channel: Combine: Asynchronous Programming with Swift - Kodeco Forums
Viewing all articles
Browse latest Browse all 26

[Combine]subscribe method

$
0
0

I know publisher has a method subscribe(_ subject: Subject)

let arrPublisher = [1,2,3,4].publisher
let tester = PassthroughSubject<Int, Never>()

arrPublisher.sink { result in
    print(result)
}.store(in: &subscriptions)
arrPublisher.subscribe(tester)
tester.send(5)

why tester as a subject cant send data after publisher has subscribed it.

3 posts - 3 participants

Read full topic


Viewing all articles
Browse latest Browse all 26

Trending Articles