Skip to content

Commit df65474

Browse files
committed
Shared(require:) should throw errors with default shared keys (#38)
1 parent ae10560 commit df65474

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Sources/Sharing/SharedKeys/DefaultKey.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public struct _SharedKeyDefault<Base: SharedReaderKey>: SharedReaderKey {
4646
}
4747

4848
public func load(initialValue: Base.Value?) -> Base.Value? {
49-
base.load(initialValue: initialValue ?? defaultValue())
49+
base.load(initialValue: initialValue)
5050
}
5151

5252
public func subscribe(

Tests/SharingTests/DefaultTests.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ import Testing
8484
#expect(isOn == true)
8585
}
8686
}
87+
88+
@Test func requireShouldThrow() {
89+
withKnownIssue {
90+
_ = try Shared(require: .isOn)
91+
}
92+
}
8793
}
8894

8995
extension SharedReaderKey where Self == InMemoryKey<Bool>.Default {

0 commit comments

Comments
 (0)