Files
letro-ios/ElementX/Sources/Other/SwiftUI/ViewModel/BindableState.swift
Mauro 6160c44d67 Update copyright holding and dates (#4640)
* Update copyright holding and dates

* compound IDE Macros updated

* update copyright

* update copyrights done

* update templates and README
2025-10-21 14:34:56 +02:00

29 lines
962 B
Swift

//
// Copyright 2025 Element Creations Ltd.
// Copyright 2022-2025 New Vector Ltd.
//
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
// Please see LICENSE files in the repository root for full details.
//
import Foundation
/// Represents a specific portion of the ViewState that can be bound to with SwiftUI's [2-way binding](https://developer.apple.com/documentation/swiftui/binding).
@MainActor
protocol BindableState {
/// The associated type of the Bindable State. Defaults to Void.
associatedtype BindStateType = Void
var bindings: BindStateType { get set }
}
extension BindableState where BindStateType == Void {
/// We provide a default implementation for the Void type so that we can have `ViewState` that
/// just doesn't include/take advantage of the bindings.
var bindings: Void {
get { }
set {
fatalError("Can't bind to the default Void binding.")
}
}
}