Slide 45
Slide 45 text
struct FormAction: Equatable {
// ...
static func set(
_ keyPath: WritableKeyPath,
_ value: Value
) where Value: Hashable -> Self {
self.init(keyPath, value)
}
}
//
テストは以下のように書けるようになる
store.assert(
//
より直感的になった
.send(.form(.set(\.displayName, "Blob"))) {
$0.displayName = "Blob"
},
.send(.form(.set(\.displayName, "Blob McBlob, Esq."))) {
$0.displayName = "Blob McBlob, Esq"
},
.send(.form(.set(\.protectPosts, true))) {
$0.protectPosts = true
},
.send(.form(.set(\.digest, .weekly))) {
$0.digest = .weekly
}
)
45