Closed m0rt3nlund closed 1 year ago
Feel free to send a PR but there are several caveats to applying this optimization:
Given it only applies in every limited cases and the payload is small, we won't chase it, but I will be glad to review if you want to work on it. :) Thanks!
Environment
Actual behavior
Using a Live.Component and issuing
send_update
to it, then responding with no change in theupdate/2
callback, returning{:ok, socket}
and Liveview will still send a diff to the client:%{c: %{}}
even though this isnoop
I think the problem is located here: https://github.com/phoenixframework/phoenix_live_view/blob/v0.20.1/lib/phoenix_live_view/diff.ex#L214C56-L214C56
This will return a map where the
:c
key is set. Since there is no actual change this should not have been set for functionality further down the diff track to be able to returnnoop
And this this is expecting an empty map, to say "noop", but due to the lines above it receives
%{c: %{}}
https://github.com/phoenixframework/phoenix_live_view/blob/v0.20.1/lib/phoenix_live_view/channel.ex#L901C41-L901C41Expected behavior
Expects no diff to be sent to the client when there is no changes in the assigns of the Live.Component
Possible solution could be something like: