Target macOS 10.15, iOS 13, tvOS 13, watchOS 6
This commit is contained in:
parent
60013d90e2
commit
ea11b7ac4f
|
@ -4,10 +4,10 @@ import PackageDescription
|
|||
let package = Package(
|
||||
name: "Defaults",
|
||||
platforms: [
|
||||
.macOS(.v10_13),
|
||||
.iOS(.v12),
|
||||
.tvOS(.v12),
|
||||
.watchOS(.v5)
|
||||
.macOS(.v10_15),
|
||||
.iOS(.v13),
|
||||
.tvOS(.v13),
|
||||
.watchOS(.v6)
|
||||
],
|
||||
products: [
|
||||
.library(
|
||||
|
|
|
@ -75,6 +75,8 @@ extension Defaults {
|
|||
// Key Type UserDefaults name Default value
|
||||
}
|
||||
```
|
||||
|
||||
- Warning: The key must be ASCII, not start with `@`, and cannot contain a dot (`.`).
|
||||
*/
|
||||
public final class Key<Value: Serializable>: _AnyKey {
|
||||
/**
|
||||
|
|
|
@ -6,7 +6,6 @@ extension Defaults {
|
|||
/**
|
||||
Custom `Subscription` for `UserDefaults` key observation.
|
||||
*/
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
final class DefaultsSubscription<SubscriberType: Subscriber>: Subscription where SubscriberType.Input == BaseChange {
|
||||
private var subscriber: SubscriberType?
|
||||
private var observation: UserDefaultsKeyObservation?
|
||||
|
@ -43,7 +42,6 @@ extension Defaults {
|
|||
/**
|
||||
Custom Publisher, which is using DefaultsSubscription.
|
||||
*/
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
struct DefaultsPublisher: Publisher {
|
||||
typealias Output = BaseChange
|
||||
typealias Failure = Never
|
||||
|
@ -87,7 +85,6 @@ extension Defaults {
|
|||
}
|
||||
```
|
||||
*/
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
public static func publisher<Value: Serializable>(
|
||||
_ key: Key<Value>,
|
||||
options: ObservationOptions = [.initial]
|
||||
|
@ -101,7 +98,6 @@ extension Defaults {
|
|||
/**
|
||||
Publisher for multiple `Key<T>` observation, but without specific information about changes.
|
||||
*/
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
public static func publisher(
|
||||
keys: _AnyKey...,
|
||||
options: ObservationOptions = [.initial]
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
#if canImport(Combine)
|
||||
import SwiftUI
|
||||
import Combine
|
||||
|
||||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
extension Defaults {
|
||||
@MainActor
|
||||
final class Observable<Value: Serializable>: ObservableObject {
|
||||
|
@ -67,7 +65,6 @@ Access stored values from SwiftUI.
|
|||
|
||||
This is similar to `@AppStorage` but it accepts a ``Defaults/Key`` and many more types.
|
||||
*/
|
||||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
@propertyWrapper
|
||||
public struct Default<Value: Defaults.Serializable>: DynamicProperty {
|
||||
public typealias Publisher = AnyPublisher<Defaults.KeyChange<Value>, Never>
|
||||
|
@ -152,7 +149,6 @@ public struct Default<Value: Defaults.Serializable>: DynamicProperty {
|
|||
}
|
||||
}
|
||||
|
||||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
extension Default where Value: Equatable {
|
||||
/**
|
||||
Indicates whether the value is the same as the default value.
|
||||
|
@ -234,7 +230,6 @@ extension Defaults.Toggle {
|
|||
}
|
||||
}
|
||||
|
||||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
extension Defaults {
|
||||
// TODO: Expose this publicly at some point.
|
||||
private static func events<Value: Serializable>(
|
||||
|
@ -257,7 +252,6 @@ extension Defaults {
|
|||
}
|
||||
}
|
||||
|
||||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
@propertyWrapper
|
||||
private struct ViewStorage<Value>: DynamicProperty {
|
||||
private final class ValueBox {
|
||||
|
@ -281,4 +275,3 @@ private struct ViewStorage<Value>: DynamicProperty {
|
|||
self._valueBox = .init(wrappedValue: ValueBox(value()))
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -368,7 +368,6 @@ final class DefaultsAnySerializableTests: XCTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveKeyCombine() {
|
||||
let key = Defaults.Key<Defaults.AnySerializable>("observeAnyKeyCombine", default: 123)
|
||||
let expect = expectation(description: "Observation closure being called")
|
||||
|
@ -396,7 +395,6 @@ final class DefaultsAnySerializableTests: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveOptionalKeyCombine() {
|
||||
let key = Defaults.Key<Defaults.AnySerializable?>("observeAnyOptionalKeyCombine")
|
||||
let expect = expectation(description: "Observation closure being called")
|
||||
|
|
|
@ -81,7 +81,6 @@ final class DefaultsArrayTests: XCTestCase {
|
|||
XCTAssertEqual(Defaults[.array][0], newName)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveKeyCombine() {
|
||||
let key = Defaults.Key<[String]>("observeArrayKeyCombine", default: fixtureArray)
|
||||
let newName = "Chen"
|
||||
|
@ -108,7 +107,6 @@ final class DefaultsArrayTests: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveOptionalKeyCombine() {
|
||||
let key = Defaults.Key<[String]?>("observeArrayOptionalKeyCombine")
|
||||
let newName = ["Chen"]
|
||||
|
|
|
@ -131,7 +131,6 @@ final class DefaultsCodableEnumTests: XCTestCase {
|
|||
XCTAssertNotNil(UserDefaults.standard.integer(forKey: keyName))
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveKeyCombine() {
|
||||
let key = Defaults.Key<FixtureCodableEnum>("observeCodableEnumKeyCombine", default: .tenMinutes)
|
||||
let expect = expectation(description: "Observation closure being called")
|
||||
|
@ -159,7 +158,6 @@ final class DefaultsCodableEnumTests: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveOptionalKeyCombine() {
|
||||
let key = Defaults.Key<FixtureCodableEnum?>("observeCodableEnumOptionalKeyCombine")
|
||||
let expect = expectation(description: "Observation closure being called")
|
||||
|
@ -188,7 +186,6 @@ final class DefaultsCodableEnumTests: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveArrayKeyCombine() {
|
||||
let key = Defaults.Key<[FixtureCodableEnum]>("observeCodableEnumArrayKeyCombine", default: [.tenMinutes])
|
||||
let expect = expectation(description: "Observation closure being called")
|
||||
|
@ -216,7 +213,6 @@ final class DefaultsCodableEnumTests: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveDictionaryKeyCombine() {
|
||||
let key = Defaults.Key<[String: FixtureCodableEnum]>("observeCodableEnumDictionaryKeyCombine", default: ["0": .tenMinutes])
|
||||
let expect = expectation(description: "Observation closure being called")
|
||||
|
|
|
@ -162,7 +162,6 @@ final class DefaultsCodableTests: XCTestCase {
|
|||
XCTAssertNotNil(UserDefaults.standard.data(forKey: keyName))
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveKeyCombine() {
|
||||
let key = Defaults.Key<Unicorn>("observeCodableKeyCombine", default: fixtureCodable)
|
||||
let expect = expectation(description: "Observation closure being called")
|
||||
|
@ -188,7 +187,6 @@ final class DefaultsCodableTests: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveOptionalKeyCombine() {
|
||||
let key = Defaults.Key<Unicorn?>("observeCodableOptionalKeyCombine")
|
||||
let expect = expectation(description: "Observation closure being called")
|
||||
|
@ -216,7 +214,6 @@ final class DefaultsCodableTests: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveArrayKeyCombine() {
|
||||
let key = Defaults.Key<[Unicorn]>("observeCodableArrayKeyCombine", default: [fixtureCodable])
|
||||
let expect = expectation(description: "Observation closure being called")
|
||||
|
@ -242,7 +239,6 @@ final class DefaultsCodableTests: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveDictionaryKeyCombine() {
|
||||
let key = Defaults.Key<[String: Unicorn]>("observeCodableDictionaryKeyCombine", default: ["0": fixtureCodable])
|
||||
let expect = expectation(description: "Observation closure being called")
|
||||
|
|
|
@ -170,7 +170,6 @@ final class DefaultsCollectionCustomElementTests: XCTestCase {
|
|||
XCTAssertEqual(Defaults[.collectionCustomElementDictionary]["1"]?[0], fixtureCustomCollection2)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveKeyCombine() {
|
||||
let key = Defaults.Key<Bag<Item>>("observeCollectionCustomElementKeyCombine", default: .init(items: [fixtureCustomCollection]))
|
||||
let expect = expectation(description: "Observation closure being called")
|
||||
|
@ -196,7 +195,6 @@ final class DefaultsCollectionCustomElementTests: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveOptionalKeyCombine() {
|
||||
let key = Defaults.Key<Bag<Item>?>("observeCollectionCustomElementOptionalKeyCombine")
|
||||
let expect = expectation(description: "Observation closure being called")
|
||||
|
@ -225,7 +223,6 @@ final class DefaultsCollectionCustomElementTests: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveArrayKeyCombine() {
|
||||
let key = Defaults.Key<[Bag<Item>]>("observeCollectionCustomElementArrayKeyCombine", default: [.init(items: [fixtureCustomCollection])])
|
||||
let expect = expectation(description: "Observation closure being called")
|
||||
|
@ -251,7 +248,6 @@ final class DefaultsCollectionCustomElementTests: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveDictionaryKeyCombine() {
|
||||
let key = Defaults.Key<[String: Bag<Item>]>("observeCollectionCustomElementDictionaryKeyCombine", default: ["0": .init(items: [fixtureCustomCollection])])
|
||||
let expect = expectation(description: "Observation closure being called")
|
||||
|
|
|
@ -156,7 +156,6 @@ final class DefaultsCollectionTests: XCTestCase {
|
|||
XCTAssertEqual(Defaults[.collectionDictionary]["1"]?[0], fixtureCollection[0])
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveKeyCombine() {
|
||||
let key = Defaults.Key<Bag<String>>("observeCollectionKeyCombine", default: .init(items: fixtureCollection))
|
||||
let item = "Grape"
|
||||
|
@ -183,7 +182,6 @@ final class DefaultsCollectionTests: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveOptionalKeyCombine() {
|
||||
let key = Defaults.Key<Bag<String>?>("observeCollectionOptionalKeyCombine")
|
||||
let item = "Grape"
|
||||
|
@ -213,7 +211,6 @@ final class DefaultsCollectionTests: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveArrayKeyCombine() {
|
||||
let key = Defaults.Key<[Bag<String>]>("observeCollectionArrayKeyCombine", default: [.init(items: fixtureCollection)])
|
||||
let item = "Grape"
|
||||
|
@ -240,7 +237,6 @@ final class DefaultsCollectionTests: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveDictionaryKeyCombine() {
|
||||
let key = Defaults.Key<[String: Bag<String>]>("observeCollectionArrayKeyCombine", default: ["0": .init(items: fixtureCollection)])
|
||||
let item = "Grape"
|
||||
|
|
|
@ -242,7 +242,6 @@ final class DefaultsCustomBridge: XCTestCase {
|
|||
XCTAssertEqual(Defaults[.customBridgeDictionary]["0"], newUser)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveKeyCombine() {
|
||||
let key = Defaults.Key<User>("observeCustomBridgeKeyCombine", default: fixtureCustomBridge)
|
||||
let newUser = User(username: "sindresorhus", password: "123456789")
|
||||
|
@ -269,7 +268,6 @@ final class DefaultsCustomBridge: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveOptionalKeyCombine() {
|
||||
let key = Defaults.Key<User?>("observeCustomBridgeOptionalKeyCombine")
|
||||
let newUser = User(username: "sindresorhus", password: "123456789")
|
||||
|
@ -299,7 +297,6 @@ final class DefaultsCustomBridge: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveArrayKeyCombine() {
|
||||
let key = Defaults.Key<[User]>("observeCustomBridgeArrayKeyCombine", default: [fixtureCustomBridge])
|
||||
let newUser = User(username: "sindresorhus", password: "123456789")
|
||||
|
@ -326,7 +323,6 @@ final class DefaultsCustomBridge: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveDictionaryCombine() {
|
||||
let key = Defaults.Key<[String: User]>("observeCustomBridgeDictionaryKeyCombine", default: ["0": fixtureCustomBridge])
|
||||
let newUser = User(username: "sindresorhus", password: "123456789")
|
||||
|
|
|
@ -64,7 +64,6 @@ final class DefaultsDictionaryTests: XCTestCase {
|
|||
XCTAssertEqual(Defaults[.dictionary]["0"], newName)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveKeyCombine() {
|
||||
let key = Defaults.Key<[String: String]>("observeDictionaryKeyCombine", default: fixtureDictionary)
|
||||
let expect = expectation(description: "Observation closure being called")
|
||||
|
@ -91,7 +90,6 @@ final class DefaultsDictionaryTests: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveOptionalKeyCombine() {
|
||||
let key = Defaults.Key<[String: String]?>("observeDictionaryOptionalKeyCombine")
|
||||
let expect = expectation(description: "Observation closure being called")
|
||||
|
|
|
@ -116,7 +116,6 @@ final class DefaultsEnumTests: XCTestCase {
|
|||
XCTAssertEqual(Defaults[.enumDictionary]["0"], .halfHour)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveKeyCombine() {
|
||||
let key = Defaults.Key<FixtureEnum>("observeEnumKeyCombine", default: .tenMinutes)
|
||||
let expect = expectation(description: "Observation closure being called")
|
||||
|
@ -146,7 +145,6 @@ final class DefaultsEnumTests: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveOptionalKeyCombine() {
|
||||
let key = Defaults.Key<FixtureEnum?>("observeEnumOptionalKeyCombine")
|
||||
let expect = expectation(description: "Observation closure being called")
|
||||
|
@ -176,7 +174,6 @@ final class DefaultsEnumTests: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveArrayKeyCombine() {
|
||||
let key = Defaults.Key<[FixtureEnum]>("observeEnumArrayKeyCombine", default: [.tenMinutes])
|
||||
let expect = expectation(description: "Observation closure being called")
|
||||
|
@ -205,7 +202,6 @@ final class DefaultsEnumTests: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveDictionaryKeyCombine() {
|
||||
let key = Defaults.Key<[String: FixtureEnum]>("observeEnumDictionaryKeyCombine", default: ["0": .tenMinutes])
|
||||
let expect = expectation(description: "Observation closure being called")
|
||||
|
|
|
@ -126,7 +126,6 @@ final class DefaultsNSColorTests: XCTestCase {
|
|||
XCTAssertTrue(Defaults[.colorDictionary]["0"]?.isEqual(fixtureColor1) ?? false)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveKeyCombine() {
|
||||
let key = Defaults.Key<NSColor>("observeNSColorKeyCombine", default: fixtureColor)
|
||||
let expect = expectation(description: "Observation closure being called")
|
||||
|
@ -152,7 +151,6 @@ final class DefaultsNSColorTests: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveOptionalKeyCombine() {
|
||||
let key = Defaults.Key<NSColor?>("observeNSColorOptionalKeyCombine")
|
||||
let expect = expectation(description: "Observation closure being called")
|
||||
|
@ -189,7 +187,6 @@ final class DefaultsNSColorTests: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveArrayKeyCombine() {
|
||||
let key = Defaults.Key<[NSColor]>("observeNSColorArrayKeyCombine", default: [fixtureColor])
|
||||
let expect = expectation(description: "Observation closure being called")
|
||||
|
@ -215,7 +212,6 @@ final class DefaultsNSColorTests: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveDictionaryKeyCombine() {
|
||||
let key = Defaults.Key<[String: NSColor]>("observeNSColorDictionaryKeyCombine", default: ["0": fixtureColor])
|
||||
let expect = expectation(description: "Observation closure being called")
|
||||
|
|
|
@ -158,7 +158,6 @@ final class DefaultsNSSecureCodingTests: XCTestCase {
|
|||
XCTAssertEqual(Defaults[.persistentHistoryDictionary]["0"]?.value, newPersistentHistory.value)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveKeyCombine() {
|
||||
let key = Defaults.Key<ExamplePersistentHistory>("observeNSSecureCodingKeyCombine", default: persistentHistoryValue)
|
||||
let newPersistentHistory = ExamplePersistentHistory(value: "NewValue")
|
||||
|
@ -185,7 +184,6 @@ final class DefaultsNSSecureCodingTests: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveOptionalKeyCombine() {
|
||||
let key = Defaults.Key<ExamplePersistentHistory?>("observeNSSecureCodingOptionalKeyCombine")
|
||||
let newPersistentHistory = ExamplePersistentHistory(value: "NewValue")
|
||||
|
@ -215,7 +213,6 @@ final class DefaultsNSSecureCodingTests: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveArrayKeyCombine() {
|
||||
let key = Defaults.Key<[ExamplePersistentHistory]>("observeNSSecureCodingArrayKeyCombine", default: [persistentHistoryValue])
|
||||
let newPersistentHistory = ExamplePersistentHistory(value: "NewValue")
|
||||
|
@ -244,7 +241,6 @@ final class DefaultsNSSecureCodingTests: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveDictionaryKeyCombine() {
|
||||
let key = Defaults.Key<[String: ExamplePersistentHistory]>("observeNSSecureCodingDictionaryKeyCombine", default: ["0": persistentHistoryValue])
|
||||
let newPersistentHistory = ExamplePersistentHistory(value: "NewValue")
|
||||
|
@ -273,7 +269,6 @@ final class DefaultsNSSecureCodingTests: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveMultipleNSSecureKeysCombine() {
|
||||
let key1 = Defaults.Key<ExamplePersistentHistory>("observeMultipleNSSecureCodingKey1", default: ExamplePersistentHistory(value: "TestValue"))
|
||||
let key2 = Defaults.Key<ExamplePersistentHistory>("observeMultipleNSSecureCodingKey2", default: ExamplePersistentHistory(value: "TestValue"))
|
||||
|
@ -292,7 +287,6 @@ final class DefaultsNSSecureCodingTests: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveMultipleNSSecureOptionalKeysCombine() {
|
||||
let key1 = Defaults.Key<ExamplePersistentHistory?>("observeMultipleNSSecureCodingOptionalKey1")
|
||||
let key2 = Defaults.Key<ExamplePersistentHistory?>("observeMultipleNSSecureCodingOptionalKeyKey2")
|
||||
|
@ -334,73 +328,71 @@ final class DefaultsNSSecureCodingTests: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testRemoveDuplicatesObserveNSSecureCodingKeyCombine() {
|
||||
let key = Defaults.Key<ExamplePersistentHistory>("observeNSSecureCodingKey", default: ExamplePersistentHistory(value: "TestValue"))
|
||||
let expect = expectation(description: "Observation closure being called")
|
||||
func testRemoveDuplicatesObserveNSSecureCodingKeyCombine() {
|
||||
let key = Defaults.Key<ExamplePersistentHistory>("observeNSSecureCodingKey", default: ExamplePersistentHistory(value: "TestValue"))
|
||||
let expect = expectation(description: "Observation closure being called")
|
||||
|
||||
let inputArray = ["NewTestValue", "NewTestValue", "NewTestValue", "NewTestValue2", "NewTestValue2", "NewTestValue2", "NewTestValue3", "NewTestValue3"]
|
||||
let expectedArray = ["NewTestValue", "NewTestValue2", "NewTestValue3"]
|
||||
let inputArray = ["NewTestValue", "NewTestValue", "NewTestValue", "NewTestValue2", "NewTestValue2", "NewTestValue2", "NewTestValue3", "NewTestValue3"]
|
||||
let expectedArray = ["NewTestValue", "NewTestValue2", "NewTestValue3"]
|
||||
|
||||
let cancellable = Defaults
|
||||
.publisher(key, options: [])
|
||||
.removeDuplicates()
|
||||
.map(\.newValue.value)
|
||||
.collect(expectedArray.count)
|
||||
.sink { result in
|
||||
print("Result array: \(result)")
|
||||
let cancellable = Defaults
|
||||
.publisher(key, options: [])
|
||||
.removeDuplicates()
|
||||
.map(\.newValue.value)
|
||||
.collect(expectedArray.count)
|
||||
.sink { result in
|
||||
print("Result array: \(result)")
|
||||
|
||||
if result == expectedArray {
|
||||
expect.fulfill()
|
||||
} else {
|
||||
XCTFail("Expected Array is not matched")
|
||||
}
|
||||
if result == expectedArray {
|
||||
expect.fulfill()
|
||||
} else {
|
||||
XCTFail("Expected Array is not matched")
|
||||
}
|
||||
|
||||
inputArray.forEach {
|
||||
Defaults[key] = ExamplePersistentHistory(value: $0)
|
||||
}
|
||||
|
||||
Defaults.reset(key)
|
||||
cancellable.cancel()
|
||||
|
||||
waitForExpectations(timeout: 10)
|
||||
inputArray.forEach {
|
||||
Defaults[key] = ExamplePersistentHistory(value: $0)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testRemoveDuplicatesObserveNSSecureCodingOptionalKeyCombine() {
|
||||
let key = Defaults.Key<ExamplePersistentHistory?>("observeNSSecureCodingOptionalKey")
|
||||
let expect = expectation(description: "Observation closure being called")
|
||||
Defaults.reset(key)
|
||||
cancellable.cancel()
|
||||
|
||||
let inputArray = ["NewTestValue", "NewTestValue", "NewTestValue", "NewTestValue2", "NewTestValue2", "NewTestValue2", "NewTestValue3", "NewTestValue3"]
|
||||
let expectedArray = ["NewTestValue", "NewTestValue2", "NewTestValue3", nil]
|
||||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
let cancellable = Defaults
|
||||
.publisher(key, options: [])
|
||||
.removeDuplicates()
|
||||
.map(\.newValue)
|
||||
.map { $0?.value }
|
||||
.collect(expectedArray.count)
|
||||
.sink { result in
|
||||
print("Result array: \(result)")
|
||||
func testRemoveDuplicatesObserveNSSecureCodingOptionalKeyCombine() {
|
||||
let key = Defaults.Key<ExamplePersistentHistory?>("observeNSSecureCodingOptionalKey")
|
||||
let expect = expectation(description: "Observation closure being called")
|
||||
|
||||
if result == expectedArray {
|
||||
expect.fulfill()
|
||||
} else {
|
||||
XCTFail("Expected Array is not matched")
|
||||
}
|
||||
let inputArray = ["NewTestValue", "NewTestValue", "NewTestValue", "NewTestValue2", "NewTestValue2", "NewTestValue2", "NewTestValue3", "NewTestValue3"]
|
||||
let expectedArray = ["NewTestValue", "NewTestValue2", "NewTestValue3", nil]
|
||||
|
||||
let cancellable = Defaults
|
||||
.publisher(key, options: [])
|
||||
.removeDuplicates()
|
||||
.map(\.newValue)
|
||||
.map { $0?.value }
|
||||
.collect(expectedArray.count)
|
||||
.sink { result in
|
||||
print("Result array: \(result)")
|
||||
|
||||
if result == expectedArray {
|
||||
expect.fulfill()
|
||||
} else {
|
||||
XCTFail("Expected Array is not matched")
|
||||
}
|
||||
|
||||
inputArray.forEach {
|
||||
Defaults[key] = ExamplePersistentHistory(value: $0)
|
||||
}
|
||||
|
||||
Defaults.reset(key)
|
||||
cancellable.cancel()
|
||||
|
||||
waitForExpectations(timeout: 10)
|
||||
inputArray.forEach {
|
||||
Defaults[key] = ExamplePersistentHistory(value: $0)
|
||||
}
|
||||
|
||||
Defaults.reset(key)
|
||||
cancellable.cancel()
|
||||
|
||||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
func testObserveKey() {
|
||||
let key = Defaults.Key<ExamplePersistentHistory>("observeNSSecureCodingKey", default: persistentHistoryValue)
|
||||
let newPersistentHistory = ExamplePersistentHistory(value: "NewValue")
|
||||
|
|
|
@ -174,7 +174,6 @@ final class DefaultsSetAlgebraCustomElementTests: XCTestCase {
|
|||
XCTAssertEqual(Defaults[.setAlgebraCustomElementDictionary]["1"], .init([fixtureSetAlgebra2, fixtureSetAlgebra3]))
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveKeyCombine() {
|
||||
let key = Defaults.Key<DefaultsSetAlgebra<Item>>("observeSetAlgebraKeyCombine", default: .init([fixtureSetAlgebra]))
|
||||
let expect = expectation(description: "Observation closure being called")
|
||||
|
@ -202,7 +201,6 @@ final class DefaultsSetAlgebraCustomElementTests: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveOptionalKeyCombine() {
|
||||
let key = Defaults.Key<DefaultsSetAlgebra<Item>?>("observeSetAlgebraOptionalKeyCombine")
|
||||
let expect = expectation(description: "Observation closure being called")
|
||||
|
@ -231,7 +229,6 @@ final class DefaultsSetAlgebraCustomElementTests: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveArrayKeyCombine() {
|
||||
let key = Defaults.Key<[DefaultsSetAlgebra<Item>]>("observeSetAlgebraArrayKeyCombine", default: [.init([fixtureSetAlgebra])])
|
||||
let expect = expectation(description: "Observation closure being called")
|
||||
|
@ -259,7 +256,6 @@ final class DefaultsSetAlgebraCustomElementTests: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveDictionaryKeyCombine() {
|
||||
let key = Defaults.Key<[String: DefaultsSetAlgebra<Item>]>("observeSetAlgebraDictionaryKeyCombine", default: ["0": .init([fixtureSetAlgebra])])
|
||||
let expect = expectation(description: "Observation closure being called")
|
||||
|
|
|
@ -206,7 +206,6 @@ final class DefaultsSetAlgebraTests: XCTestCase {
|
|||
XCTAssertEqual(Defaults[.setAlgebraDictionary]["1"], .init([fixtureSetAlgebra2, fixtureSetAlgebra3]))
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveKeyCombine() {
|
||||
let key = Defaults.Key<DefaultsSetAlgebra<Int>>("observeSetAlgebraKeyCombine", default: .init([fixtureSetAlgebra]))
|
||||
let expect = expectation(description: "Observation closure being called")
|
||||
|
@ -234,7 +233,6 @@ final class DefaultsSetAlgebraTests: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveOptionalKeyCombine() {
|
||||
let key = Defaults.Key<DefaultsSetAlgebra<Int>?>("observeSetAlgebraOptionalKeyCombine")
|
||||
let expect = expectation(description: "Observation closure being called")
|
||||
|
@ -263,7 +261,6 @@ final class DefaultsSetAlgebraTests: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveArrayKeyCombine() {
|
||||
let key = Defaults.Key<[DefaultsSetAlgebra<Int>]>("observeSetAlgebraArrayKeyCombine", default: [.init([fixtureSetAlgebra])])
|
||||
let expect = expectation(description: "Observation closure being called")
|
||||
|
@ -291,7 +288,6 @@ final class DefaultsSetAlgebraTests: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveDictionaryKeyCombine() {
|
||||
let key = Defaults.Key<[String: DefaultsSetAlgebra<Int>]>("observeSetAlgebraDictionaryKeyCombine", default: ["0": .init([fixtureSetAlgebra])])
|
||||
let expect = expectation(description: "Observation closure being called")
|
||||
|
|
|
@ -167,7 +167,6 @@ final class DefaultsTests: XCTestCase {
|
|||
Defaults.removeAll(suite: customSuite)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveKeyCombine() {
|
||||
let key = Defaults.Key<Bool>("observeKey", default: false)
|
||||
let expect = expectation(description: "Observation closure being called")
|
||||
|
@ -193,7 +192,6 @@ final class DefaultsTests: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveOptionalKeyCombine() {
|
||||
let key = Defaults.Key<Bool?>("observeOptionalKey")
|
||||
let expect = expectation(description: "Observation closure being called")
|
||||
|
@ -222,7 +220,6 @@ final class DefaultsTests: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testDynamicOptionalDateTypeCombine() {
|
||||
let first = Date(timeIntervalSince1970: 0)
|
||||
let second = Date(timeIntervalSince1970: 1)
|
||||
|
@ -254,7 +251,6 @@ final class DefaultsTests: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveMultipleKeysCombine() {
|
||||
let key1 = Defaults.Key<String>("observeKey1", default: "x")
|
||||
let key2 = Defaults.Key<Bool>("observeKey2", default: true)
|
||||
|
@ -273,7 +269,6 @@ final class DefaultsTests: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveMultipleOptionalKeysCombine() {
|
||||
let key1 = Defaults.Key<String?>("observeOptionalKey1")
|
||||
let key2 = Defaults.Key<Bool?>("observeOptionalKey2")
|
||||
|
@ -292,7 +287,6 @@ final class DefaultsTests: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testReceiveValueBeforeSubscriptionCombine() {
|
||||
let key = Defaults.Key<String>("receiveValueBeforeSubscription", default: "hello")
|
||||
let expect = expectation(description: "Observation closure being called")
|
||||
|
@ -502,7 +496,6 @@ final class DefaultsTests: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObservePreventPropagationCombine() {
|
||||
let key1 = Defaults.Key<Bool?>("preventPropagation6", default: nil)
|
||||
let expect = expectation(description: "No infinite recursion")
|
||||
|
@ -523,7 +516,6 @@ final class DefaultsTests: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObservePreventPropagationMultipleKeysCombine() {
|
||||
let key1 = Defaults.Key<Bool?>("preventPropagation7", default: nil)
|
||||
let key2 = Defaults.Key<Bool?>("preventPropagation8", default: nil)
|
||||
|
@ -545,7 +537,6 @@ final class DefaultsTests: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObservePreventPropagationModifiersCombine() {
|
||||
let key1 = Defaults.Key<Bool?>("preventPropagation9", default: nil)
|
||||
let expect = expectation(description: "No infinite recursion")
|
||||
|
@ -570,7 +561,6 @@ final class DefaultsTests: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testRemoveDuplicatesObserveKeyCombine() {
|
||||
let key = Defaults.Key<Bool>("observeKey", default: false)
|
||||
let expect = expectation(description: "Observation closure being called")
|
||||
|
@ -603,7 +593,6 @@ final class DefaultsTests: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testRemoveDuplicatesOptionalObserveKeyCombine() {
|
||||
let key = Defaults.Key<Bool?>("observeOptionalKey", default: nil)
|
||||
let expect = expectation(description: "Observation closure being called")
|
||||
|
@ -720,7 +709,6 @@ final class DefaultsTests: XCTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testImmediatelyFinishingPublisherCombine() {
|
||||
let key = Defaults.Key<Bool>("observeKey", default: false)
|
||||
let expect = expectation(description: "Observation closure being called without crashing")
|
||||
|
|
|
@ -125,7 +125,6 @@ final class DefaultsNSColorTests: XCTestCase {
|
|||
XCTAssertTrue(Defaults[.colorDictionary]["0"]?.isEqual(fixtureColor1) ?? false)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveKeyCombine() {
|
||||
let key = Defaults.Key<UIColor>("observeNSColorKeyCombine", default: fixtureColor)
|
||||
let expect = expectation(description: "Observation closure being called")
|
||||
|
@ -151,7 +150,6 @@ final class DefaultsNSColorTests: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveOptionalKeyCombine() {
|
||||
let key = Defaults.Key<UIColor?>("observeNSColorOptionalKeyCombine")
|
||||
let expect = expectation(description: "Observation closure being called")
|
||||
|
@ -188,7 +186,6 @@ final class DefaultsNSColorTests: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveArrayKeyCombine() {
|
||||
let key = Defaults.Key<[UIColor]>("observeNSColorArrayKeyCombine", default: [fixtureColor])
|
||||
let expect = expectation(description: "Observation closure being called")
|
||||
|
@ -214,7 +211,6 @@ final class DefaultsNSColorTests: XCTestCase {
|
|||
waitForExpectations(timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOSApplicationExtension 13.0, watchOSApplicationExtension 6.0, *)
|
||||
func testObserveDictionaryKeyCombine() {
|
||||
let key = Defaults.Key<[String: UIColor]>("observeNSColorDictionaryKeyCombine", default: ["0": fixtureColor])
|
||||
let expect = expectation(description: "Observation closure being called")
|
||||
|
|
12
readme.md
12
readme.md
|
@ -33,10 +33,10 @@ For a real-world example, see the [Plash app](https://github.com/sindresorhus/Pl
|
|||
|
||||
## Compatibility
|
||||
|
||||
- macOS 10.13+
|
||||
- iOS 12+
|
||||
- tvOS 12+
|
||||
- watchOS 5+
|
||||
- macOS 10.15+
|
||||
- iOS 13+
|
||||
- tvOS 13+
|
||||
- watchOS 6+
|
||||
|
||||
## Migration Guides
|
||||
|
||||
|
@ -517,16 +517,12 @@ Type: `func`
|
|||
|
||||
Observation API using [Publisher](https://developer.apple.com/documentation/combine/publisher) from the [Combine](https://developer.apple.com/documentation/combine) framework.
|
||||
|
||||
Available on macOS 10.15+, iOS 13.0+, tvOS 13.0+, and watchOS 6.0+.
|
||||
|
||||
#### `Defaults.publisher(keys: keys…, options:)`
|
||||
|
||||
Type: `func`
|
||||
|
||||
[Combine](https://developer.apple.com/documentation/combine) observation API for multiple key observation, but without specific information about changes.
|
||||
|
||||
Available on macOS 10.15+, iOS 13.0+, tvOS 13.0+, and watchOS 6.0+.
|
||||
|
||||
#### `Defaults.removeAll`
|
||||
|
||||
```swift
|
||||
|
|
Loading…
Reference in New Issue