I would reconsider piping the result of a Repo call into a broadcast function. Clearly the broadcasting should only be done when the Repo call was successful, but it is not the PubSub's responsibility to check the result of a Repo call.
def broadcast_record({:ok, record}, event) when is_struct(record) do
Phoenix.PubSub.broadcast(MyApp.PubSub, @topic, {event, record})
{:ok, record}
end
def broadcast_record({:error, reason}, _event), do: {:error, reason}
Could be:
def broadcast(record, event) when is_struct(record) do
Phoenix.PubSub.broadcast(MyApp.PubSub, @topic, {event, record})
end
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I would reconsider piping the result of a
Repo
call into a broadcast function. Clearly the broadcasting should only be done when theRepo
call was successful, but it is not thePubSub
's responsibility to check the result of aRepo
call.Could be: