Skip to content

Instantly share code, notes, and snippets.

@eunjin3786
Created June 28, 2019 04:26
Show Gist options
  • Save eunjin3786/221aa1734890340b82f6367a1326c68f to your computer and use it in GitHub Desktop.
Save eunjin3786/221aa1734890340b82f6367a1326c68f to your computer and use it in GitHub Desktop.
RxSwift vs Combine
let subject = PublishSubject<String>()
subject.onNext("Is anyone listening?")
let subcription1 = subject.subscribe { event in
print("1) \(event)")
}
let subcription2 = subject.subscribe { event in
print("2) \(event)")
}
subject.onNext("Hello")
subject.onCompleted()
subject.onNext("Is alive?")
<Output>
1) next(Hello)
2) next(Hello)
1) completed
2) completed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment