Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PublishSubject Example
enum SubjectError: Error {
case unknown
}
let subject = PublishSubject<Int>()
subject.onNext(1)
subject.subscribe(onNext: { value in
print(value)
}).addDisposableTo(disposeBag)
subject.onNext(2)
subject.onNext(3)
subject.onError(SubjectError.unknown)
subject.onNext(4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment