Skip to content

Instantly share code, notes, and snippets.

@eunjin3786
Created June 28, 2019 05:10
Show Gist options
  • Save eunjin3786/f369db0a510af19e4f36bb595b25b31a to your computer and use it in GitHub Desktop.
Save eunjin3786/f369db0a510af19e4f36bb595b25b31a to your computer and use it in GitHub Desktop.
let subject = BehaviorSubject<String>.init(value: "Init Value")
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(Is anyone listening?)
2) next(Is anyone listening?)
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