-
Notifications
You must be signed in to change notification settings - Fork 952
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Push pending events before redirecting #2923
Conversation
@@ -837,6 +841,11 @@ defmodule Phoenix.LiveView.Channel do | |||
end | |||
end | |||
|
|||
defp push_pending_events_on_redirect(state, socket) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider moving this function to the Diff module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the function makes sense here because it depends on push
maybe we could add a get_push_events
function to Diff
which returns either {"diff", %{e: events}} or nil
?
Presumably the goal here is to avoid the duplication of "diff" and @events
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. get_push_events sounds good to me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4cf29a0
to
8aa91ac
Compare
Previously, there was no way to handle both `push_event` and `push_redirect` occuring in the same callback. The redirect would prevent the events from being sent. This commit checks the diff for any new events, and if they exist, sends them over the channel.
8aa91ac
to
ec3566e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ship it!
Previously, there was no way to handle both
push_event
andpush_redirect
occuring in the same callback. The redirect would prevent the events from being sent. This commit checks the diff for any new events, and if they exist, sends them over the channel.