mirror of
https://github.com/pointfreeco/swift-composable-architecture.git
synced 2025-12-20 09:11:33 +01:00
14 lines
316 B
Swift
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
|
|
}
|
|
)
|
|
}
|
|
}
|