@@ -71,22 +71,22 @@ open class AsyncObservable<T: Sendable>: AsyncObservableReadOnly, @unchecked Sen
7171 /// The observable state object for SwiftUI/UIKit integration.
7272 /// This property is accessed on the MainActor to ensure thread-safe UI updates.
7373 @MainActor
74- public lazy var observable : State = {
75- let observable = State ( value: value , didSetValue: didUpdateFromObservable)
76- return observable
74+ public lazy var observableState : State = {
75+ let observableState = State ( value: raw , didSetValue: didUpdateFromObservable)
76+ return observableState
7777 } ( )
7878
7979 /// The current value accessible from the MainActor.
8080 /// This is a convenience property that provides direct access to the observable value.
8181 @MainActor
82- public var valueObservable : T {
83- observable . value
82+ public var observable : T {
83+ observableState . value
8484 }
8585
8686 /// An async stream of values that can be used with Swift concurrency.
8787 /// This property provides a convenient way to access the value stream without calling `stream()`.
88- public var valueStream : StreamOf < T > {
89- stream ( )
88+ public var stream : StreamOf < T > {
89+ streamOf ( )
9090 }
9191
9292 /// Storage for active stream continuations, keyed by UUID to allow multiple observers
@@ -95,13 +95,13 @@ open class AsyncObservable<T: Sendable>: AsyncObservableReadOnly, @unchecked Sen
9595
9696 /// The current value managed by this instance.
9797 /// Updates to this value are automatically propagated to all observers.
98- private var _value : T
99- public private( set) var value : T {
98+ private var _raw : T
99+ public private( set) var raw : T {
100100 get {
101- serialQueue. sync { _value }
101+ serialQueue. sync { _raw }
102102 }
103103 set {
104- serialQueue. sync { _value = newValue }
104+ serialQueue. sync { _raw = newValue }
105105 }
106106 }
107107 private var _shouldUpdateFromObservable = true
@@ -137,7 +137,7 @@ open class AsyncObservable<T: Sendable>: AsyncObservableReadOnly, @unchecked Sen
137137 }
138138 DispatchQueue . main. async {
139139 self . shouldUpdateFromObservable = false
140- self . observable . value = value
140+ self . observableState . value = value
141141 self . shouldUpdateFromObservable = true
142142 }
143143 }
@@ -164,7 +164,7 @@ open class AsyncObservable<T: Sendable>: AsyncObservableReadOnly, @unchecked Sen
164164 serialQueue: DispatchQueue = DispatchQueue ( label: " AsyncObservable " )
165165 )
166166 {
167- _value = initialValue
167+ _raw = initialValue
168168 self . bufferingPolicy = bufferingPolicy
169169 self . serialQueue = serialQueue
170170 }
@@ -189,7 +189,7 @@ open class AsyncObservable<T: Sendable>: AsyncObservableReadOnly, @unchecked Sen
189189 /// - notifyObservers: Whether to notify stream observers (default: true)
190190 /// - updateObservable: Whether to update the observable state (default: true)
191191 public func update( _ value: T , notifyObservers: Bool = true , updateObservable: Bool = true ) {
192- self . value = value
192+ self . raw = value
193193 updated ( value, notifyObservers: notifyObservers, updateObservable: updateObservable)
194194 }
195195
@@ -202,7 +202,7 @@ open class AsyncObservable<T: Sendable>: AsyncObservableReadOnly, @unchecked Sen
202202 public func update(
203203 _ cb: @escaping ( _ value: T ) -> ( T ) , notifyObservers: Bool = true , updateObservable: Bool = true
204204 ) {
205- let newValue = cb ( value )
205+ let newValue = cb ( raw )
206206 update ( newValue, notifyObservers: notifyObservers, updateObservable: updateObservable)
207207 }
208208
@@ -217,9 +217,9 @@ open class AsyncObservable<T: Sendable>: AsyncObservableReadOnly, @unchecked Sen
217217 updateObservable: Bool = true
218218 ) {
219219 serialQueue. sync {
220- cb ( & _value )
220+ cb ( & _raw )
221221 }
222- updated ( value , notifyObservers: notifyObservers, updateObservable: updateObservable)
222+ updated ( raw , notifyObservers: notifyObservers, updateObservable: updateObservable)
223223 }
224224
225225 /// Internal helper to manage stream continuations
@@ -237,7 +237,7 @@ open class AsyncObservable<T: Sendable>: AsyncObservableReadOnly, @unchecked Sen
237237 /// The stream immediately yields the current value and then yields all subsequent updates.
238238 ///
239239 /// - Returns: A StreamOf<T> instance that can be used with async/await code
240- private func stream ( ) -> StreamOf < T > {
240+ private func streamOf ( ) -> StreamOf < T > {
241241 let id = UUID ( )
242242 return StreamOf < T > (
243243 bufferingPolicy: bufferingPolicy,
@@ -248,7 +248,7 @@ open class AsyncObservable<T: Sendable>: AsyncObservableReadOnly, @unchecked Sen
248248 builder: { [ weak self] continuation in
249249 guard let self else { return }
250250 self . setContinuation ( id: id, continuation: continuation)
251- continuation. yield ( self . value )
251+ continuation. yield ( self . raw )
252252 } )
253253 }
254254}
0 commit comments