Skip to content

Commit

Permalink
adding public documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
leogdion committed May 10, 2024
1 parent 481c081 commit cc2bd8b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
9 changes: 4 additions & 5 deletions Sources/FeatherQuill/Feature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,21 @@
import SwiftUI

@Observable
/// Set of values for the Feature.
public class Feature<ValueType, UserTypeValue: UserType> {
private let featureValue: FeatureValue<ValueType>
private let availability: FeatureAvailability<UserTypeValue>

/// Binding value to use for SwiftUI Views.
public var bindingValue: Binding<ValueType> {
featureValue.bindingValue
}

/// Value of the Feature.
public var value: ValueType {
featureValue.value
}

public var isAvailable: Bool {
availability.value
}

fileprivate init(
value: FeatureValue<ValueType>,
availability: FeatureAvailability<UserTypeValue>
Expand All @@ -58,7 +57,7 @@
}

extension Feature {
public convenience init(
internal convenience init(
key: String,
defaultValue: ValueType,
userType: UserTypeValue,
Expand Down
4 changes: 4 additions & 0 deletions Sources/FeatherQuill/FeatureFlag.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,22 @@
"\(Self.self)"
}

/// Matching user for ``FeatureFlag
public static var audience: UserTypeValue {
.default
}

/// Behavior options on how to handle changes.
public static var options: AvailabilityOptions {
.default

Check warning on line 79 in Sources/FeatherQuill/FeatureFlag.swift

View check run for this annotation

Codecov / codecov/patch

Sources/FeatherQuill/FeatureFlag.swift#L78-L79

Added lines #L78 - L79 were not covered by tests
}

/// The key the ``FeatureFlag``.
public static var key: String {
FeatureFlagSuffixes.key(from: typeName)
}

/// The default value for the environment key.
public static var defaultValue: FeatherQuill.Feature<ValueType, UserTypeValue> {
.init(
key: key,
Expand Down
6 changes: 3 additions & 3 deletions Sources/FeatherQuill/FeatureValue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@
import SwiftUI

@Observable
public class FeatureValue<ValueType> {
internal class FeatureValue<ValueType> {
private let userDefaults: UserDefaults
private let key: String
private let fullKey: String
public var bindingValue: Binding<ValueType> {
internal var bindingValue: Binding<ValueType> {
.init {
self._storedValue
} set: { value in
self._storedValue = value
}
}

public var value: ValueType {
internal var value: ValueType {
let value = userDefaults.value(forKey: fullKey) as? ValueType
assert(value != nil)
return value ?? _storedValue
Expand Down

0 comments on commit cc2bd8b

Please sign in to comment.