Files
swift-composable-architectu…/Sources/ComposableArchitecture/Internal/Binding+IsPresent.swift
Stephen Celis 0cd0c3ecce Update AlertState to use new APIs (#794)
* Update AlertState to use new APIs

* fix

* Feedback

* wip

* Fix

* wip

* wip

* wip

* wip
2021-09-20 10:42:17 -04:00

14 lines
316 B
Swift

import SwiftUI
extension Binding {
func isPresent<Wrapped>() -> Binding<Bool> where Value == Wrapped? {
.init(
get: { self.wrappedValue != nil },
set: { isPresent, transaction in
guard !isPresent else { return }
self.transaction(transaction).wrappedValue = nil
}
)
}
}