dispose bag

CurrentValueSubject Example

I googled a bit for “CurrentValueSubject Example”. Surprisingly I wasn’t able to find a simple answer. So I created a few examples: Basic import UIKit import Combine class ViewController: UIViewController { var name = CurrentValueSubject<String, Never>("Jason") override func viewDidLoad() { super.viewDidLoad() setup() } func setup() { let _ = name.sink { value in print(value) // Jason, Jason Bourne } name.send("Jason Bourne") } } Basically every time you call send on a publisher, the subscriber gets a callback....

April 14, 2022 · 7 min