Replies: 1 comment 1 reply
-
Hi @samlev, If I'm not mistaken the reason I've written it like this is to protect the developer, by setting computed properties expecting something will be set. And avoiding a lot of GitHub issues about this 😄 Since LiveWire always uses the wireable trait to hydrate, we could maybe add an option over there to You're always welcome to PR such a thing. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm sure that there's a reason for it, but I would expect that a property marked with
#[Computed]
would be computed each time the object is hydrated. Because of this, I would expect that any value passed for it would simply be ignored like areadonly
property, rather than throw an exception.As it is, it makes
#[Computed]
difficult to use in situations like livewire where you want the frontend to have access to the computed property, but the hydration step throws an exception for the computed property instead of ignoring it.In some situations I can mark the computed property as
readonly
, but there are times where that is also not ideal (e.g. if a property gets changed and you want to re-compute the property some how).What would the implications be if computed properties were by default rejected alongside readonly properties instead of throwing an exception?
Beta Was this translation helpful? Give feedback.
All reactions