Skip to content

Commit

Permalink
Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
yakovmanshin committed Apr 30, 2024
1 parent 0116ebf commit 1e7a298
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,27 @@

public protocol SynchronousFeatureFlagResolverProtocol: FeatureFlagResolverProtocol {

/// Returns a value for the specified key.
///
/// - Parameter key: *Required.* The feature flag key.
func valueSync<Value>(for key: FeatureFlagKey) throws -> Value

/// Sets a new feature flag value to the first mutable store found in `configuration.stores`.
///
/// - Parameters:
/// - newValue: *Required.* The override value.
/// - key: *Required.* The feature flag key.
func setValueSync<Value>(_ newValue: Value, toMutableStoreUsing key: FeatureFlagKey) throws

/// Removes the value from the first mutable feature flag store which has one for the specified key.
///
/// - Parameter key: *Required.* The feature flag key.
func removeValueFromMutableStoreSync(using key: FeatureFlagKey) throws

}

// MARK: - Async Requirements

extension SynchronousFeatureFlagResolverProtocol {

public func value<Value>(for key: FeatureFlagKey) async throws -> Value {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,20 @@

public protocol SynchronousFeatureFlagStoreProtocol: FeatureFlagStoreProtocol {

/// Indicates whether the store contains a value that corresponds to the key.
///
/// - Parameter key: *Required.* The key.
func containsValueSync(forKey key: String) -> Bool

/// Retrieves a feature flag value by its key.
///
/// - Parameter key: *Required.* The key that points to a feature flag value in the store.
func valueSync<Value>(forKey key: String) -> Value?

}

// MARK: - Async Requirements

extension SynchronousFeatureFlagStoreProtocol {

public func containsValue(forKey key: String) async -> Bool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,27 @@

public protocol SynchronousMutableFeatureFlagStoreProtocol: SynchronousFeatureFlagStoreProtocol, MutableFeatureFlagStoreProtocol {

/// Adds the value to the store so it can be retrieved with the key later.
///
/// - Parameters:
/// - value: *Required.* The value to record.
/// - key: *Required.* The key used to address the value.
func setValueSync<Value>(_ value: Value, forKey key: String)

/// Removes the value from the store.
///
/// - Parameter key: *Required.* The key used to address the value.
func removeValueSync(forKey key: String)

/// Immediately saves changed values so they’re not lost.
///
/// + This method can be called when work with the feature flag store is finished.
func saveChangesSync()

}

// MARK: - Async Requirements

extension SynchronousMutableFeatureFlagStoreProtocol {

public func setValue<Value>(_ value: Value, forKey key: String) async {
Expand All @@ -32,6 +45,8 @@ extension SynchronousMutableFeatureFlagStoreProtocol {

}

// MARK: - Default Implementation

extension SynchronousMutableFeatureFlagStoreProtocol {

public func saveChangesSync() { }
Expand Down

0 comments on commit 1e7a298

Please sign in to comment.