Skip to content

Commit

Permalink
Expose actionHandler in FeatureFlagLocalOverriding protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
ayoy committed Nov 14, 2024
1 parent 5be1626 commit a6180b6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,16 @@ public protocol FeatureFlagLocalOverridesHandler {
///
public protocol FeatureFlagLocalOverriding: AnyObject {

/// Handle to the feature flagged.
/// Handle to the feature flagger.
///
/// It's used to query current, non-overriden state of a feature flag to
/// decide about calling `FeatureFlagLocalOverridesHandler.flagDidChange`
/// upon clearing an override.
var featureFlagger: FeatureFlagger? { get set }

/// The action handler responding to feature flag changes.
var actionHandler: FeatureFlagLocalOverridesHandler { get }

/// Returns the current override for a feature flag, or `nil` if override is not set.
func override<Flag: FeatureFlagDescribing>(for featureFlag: Flag) -> Bool?

Expand All @@ -116,9 +119,9 @@ public protocol FeatureFlagLocalOverriding: AnyObject {

public final class FeatureFlagLocalOverrides: FeatureFlagLocalOverriding {

private var persistor: FeatureFlagLocalOverridesPersistor
private var actionHandler: FeatureFlagLocalOverridesHandler
public let actionHandler: FeatureFlagLocalOverridesHandler
public weak var featureFlagger: FeatureFlagger?
private let persistor: FeatureFlagLocalOverridesPersistor

public convenience init(
keyValueStore: KeyValueStoring,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ import TestUtils
import XCTest

final class CapturingFeatureFlagOverriding: FeatureFlagLocalOverriding {

var overrideCalls: [any FeatureFlagDescribing] = []
var toggleOverideCalls: [any FeatureFlagDescribing] = []
var clearOverrideCalls: [any FeatureFlagDescribing] = []
var clearAllOverrideCallCount: Int = 0

var override: (any FeatureFlagDescribing) -> Bool? = { _ in nil }

var actionHandler: any FeatureFlagLocalOverridesHandler = CapturingFeatureFlagLocalOverridesHandler()
weak var featureFlagger: FeatureFlagger?

func override<Flag: FeatureFlagDescribing>(for featureFlag: Flag) -> Bool? {
Expand Down

0 comments on commit a6180b6

Please sign in to comment.