diff --git a/Sources/OneWay/PropertyWrappers/CopyOnWrite.swift b/Sources/OneWay/PropertyWrappers/CopyOnWrite.swift index 881b685..46e5c4b 100644 --- a/Sources/OneWay/PropertyWrappers/CopyOnWrite.swift +++ b/Sources/OneWay/PropertyWrappers/CopyOnWrite.swift @@ -5,14 +5,16 @@ // Copyright (c) 2022-2024 SeungYeop Yeom ( https://github.com/DevYeom ). // -/// A property wrapper that allows for an easy way to eliminate the cost of copying large values -/// adopt copy-on-write behavior. +/// A property wrapper that facilitates the use of copy-on-write semantics to eliminate the cost of +/// copying large values. /// -/// When applied to a field, the corresponding value will always be heap-allocated. This happens -/// because this wrapper is a class and classes are always heap-allocated. Use of this wrapper is -/// required on large value types because they can overflow the Swift runtime stack. +/// When applied to a field, the corresponding value will always be heap-allocated because this +/// wrapper uses a class, and classes in Swift are always allocated on the heap. This is especially +/// useful for large value types, as it prevents stack overflow by ensuring the value is managed on +/// the heap instead of the stack. Additionally, the copy-on-write behavior helps avoid unnecessary +/// copying when the value is not modified, improving performance. /// -/// - SeeAlso: [Advice: Use copy-on-write semantics for large values](https://github.com/apple/swift/blob/main/docs/OptimizationTips.rst#advice-use-copy-on-write-semantics-for-large-values) +/// - SeeAlso: [Advice: Use copy-on-write semantics for large values](https://github.com/swiftlang/swift/blob/swift-6.0-RELEASE/docs/OptimizationTips.rst#advice-use-copy-on-write-semantics-for-large-values) @propertyWrapper public struct CopyOnWrite { fileprivate final class Reference { diff --git a/Sources/OneWay/PropertyWrappers/Ignored.swift b/Sources/OneWay/PropertyWrappers/Ignored.swift index 9024c4c..cf64546 100644 --- a/Sources/OneWay/PropertyWrappers/Ignored.swift +++ b/Sources/OneWay/PropertyWrappers/Ignored.swift @@ -7,9 +7,10 @@ /// A property wrapper that acts like the same value, regardless of changes in its actual value. /// -/// When applied to a field and compared with an equals sign, it will always yield `true`. It is -/// useful when the actual value of the `State` changes, but rendering of the `View` is not -/// required. +/// When applied to a field and compared with an equals sign, it will always yield `true`. This +/// prevents the observers from recognizing the state as changed, even if the actual value has been +/// updated. It is particularly useful when you want to avoid triggering state changes, especially +/// in SwiftUI, where unnecessary re-renders of the `View` can be avoided. @propertyWrapper public struct Ignored { public var wrappedValue: Value diff --git a/Sources/OneWay/PropertyWrappers/Triggered.swift b/Sources/OneWay/PropertyWrappers/Triggered.swift index ac2a48e..ac3f3e6 100644 --- a/Sources/OneWay/PropertyWrappers/Triggered.swift +++ b/Sources/OneWay/PropertyWrappers/Triggered.swift @@ -9,8 +9,9 @@ /// the same value is assigned. /// /// When applied to a field, assigning the same value will lead to different values for comparison. -/// It is useful in cases where the value hasn't actually changed, but the `View` needs to be -/// rendered again. +/// This ensures that observers will perceive the state as changed, even if the value itself remains +/// the same. It is particularly useful in SwiftUI, as it can trigger the `View` to re-render when +/// necessary, even if the value hasn't technically changed. @propertyWrapper public struct Triggered where Value: Equatable { fileprivate struct Storage: Equatable { diff --git a/Sources/OneWay/Store.swift b/Sources/OneWay/Store.swift index 7f99d60..632faf5 100644 --- a/Sources/OneWay/Store.swift +++ b/Sources/OneWay/Store.swift @@ -37,7 +37,7 @@ where R.Action: Sendable, R.State: Sendable & Equatable { } /// The state stream that emits state when the state changes. Use this stream to observe the - /// state changes + /// state changes. public var states: AsyncStream package var isIdle: Bool { !isProcessing && tasks.isEmpty }