Is there a way to create a CurrentValueSubject
that is read-only?
So you could sink
it publicly, read value
publicly, but could only send
values to it internally/privately. Want to use it in a library module.
The best pattern is to have it declared private:
private let _status = CurrentValueSubject<ThisStatus?, Never>(nil)
and expose it through a computed property:
public var status: AnyPublisher<ThisStatus?, Never> {
_status
.eraseToAnyPublisher()
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With