CurrentValueSubject.swift

Home   »   CurrentValueSubject.swift

let subject = CurrentValueSubject("Test")
print(subject.value)

subject.send("Hello")
print(subject.value)

subject.send("World")
print(subject.value)

let currentSubscription = subject.sink { (value) in
    print(value)
}
//運行結果
Test
Hello
World
World

Leave a Reply

Your email address will not be published. Required fields are marked *