-
Notifications
You must be signed in to change notification settings - Fork 32
Description
We recently updated our view model from using @observableobject to @observable. The original code, which used ObservableObject, was working as expected and the latest value in timeZoneInput was correctly captured.
Old Code:
final class DummyClassViewModel: ObservableObject { }
@FormField(validator: {
DropDownValidator<RoleDummy>(message: "Selection is required")
})
var timeZoneInput: RoleDummy = RoleDummy.empty
lazy var timeZoneInputValidation = _timeZoneInputInput.validation(manager: formManager)Now, we have changed the class to use the @observable macro, which is provided by the appple , as shown below:
New Code:
@Observable
final class DummyClassViewModel { }However, after this change, we are encountering the following issue:
Error:
Property wrapper cannot be applied to a computed property.
Solution Attempt:
We tried adding @ObservationIgnored to the @formfield property wrapper, but as the name suggests, it causes the timeZoneInput to not receive the latest value.
Here is the code causing the issue:
@FormField(validator: {
NonEmptyValidator(message: "This field is required.")
})
var timeZoneInput: RoleDummy = RoleDummy.emptyExpected Behavior:
The timeZoneInput should be able to work with the property wrapper @formfield and retain the latest value as expected, without encountering the Property wrapper cannot be applied to a computed property error.
Could you please take a look at this issue and provide a solution or suggest a workaround? I have attached a screenshot for your reference.
