@@ -20,19 +20,6 @@ public protocol OnboardingEventProtocol {
2020 /// - Warning: Don’t call this method yourself.
2121 func check( )
2222
23- /// Attempts to set the specified flag to a default value.
24- ///
25- /// This method should fail silently if no default value can be inferred.
26- /// - Parameter keyPath: The key path at which to set the default value.
27- /// - Warning: Don’t call this method yourself.
28- func setDefaultValue< Flags, Value> ( at keyPath: ReferenceWritableKeyPath < Flags , Value > )
29-
30- }
31-
32- extension OnboardingEventProtocol {
33-
34- public func setDefaultValue< Flags, Value> ( at: ReferenceWritableKeyPath < Flags , Value > ) { }
35-
3623}
3724
3825/// An event that occurs when all of its constituent conditions are satisfied.
@@ -103,8 +90,10 @@ public final class OnboardingEvent<Flags, Value>: OnboardingEventProtocol where
10390 if let keyPath = self . keyPath {
10491 self . flags [ keyPath: keyPath] = self . value
10592 }
106- } else if let keyPath = self . keyPath {
107- self . setDefaultValue ( at: keyPath)
93+ } else if let keyPath = self . keyPath as? ReferenceWritableKeyPath < Flags , Bool > {
94+ self . flags [ keyPath: keyPath] = false
95+ } else if let keyPath = self . keyPath, let defaultValue = ( Value . self as? OptionalProtocol . Type) ? . none as? Value {
96+ self . flags [ keyPath: keyPath] = defaultValue
10897 }
10998 }
11099
@@ -130,16 +119,4 @@ public extension OnboardingEvent where Value == Bool {
130119 self . init ( flags: flags, settingFlagAt: keyPath, to: true , conditions: conditions)
131120 }
132121
133- func setDefaultValue( at keyPath: ReferenceWritableKeyPath < Flags , Bool > ) {
134- self . flags [ keyPath: keyPath] = false
135- }
136-
137- }
138-
139- public extension OnboardingEvent where Value: ExpressibleByNilLiteral {
140-
141- func setDefaultValue( at keyPath: ReferenceWritableKeyPath < Flags , Value > ) {
142- self . flags [ keyPath: keyPath] = nil
143- }
144-
145122}
0 commit comments