Make `Phoenix.Component.changed?/2` allowed in guard tests
RoyalIcing opened this issue · comments
Actual behavior
Phoenix.Component.changed?/2
is implemented as a standard function, which pattern matches on whether it’s a socket or vanilla map, and then checks the internal __changed__
map.
This means it cannot be used as a guard to a def
or case
clause.
Expected behavior
It would be really useful to be able to use changed?/2
on specific clauses, as it would help simplify the logic for saying whether something needed to be reloaded or not. This check could be done at a higher level like def
/defp
. Or even within a case
clause it would be very useful.
I’m not sure how difficult it would be to change to a guard, especially since it takes two arguments.
This is the wrong repo but I am 99% sure this was discussed in LiveView's repo. the issue of making it a guard is that we cannot raise and, if we need to add more logic in the future, we are quite constrained. :)
Oh d’oh! URL autocomplete fail on my behalf 🤦🏻♂️. Makes sense, thank you!