Reply-Function for LiveViews

Yes, IMO this is the right way to see it in the context of a LiveView pipeline. We’re transforming the socket except in the last step when we’re returing a tuple. And as such we should not hide this in a opaque pipe step. But I like the shortcut |> noreply() too much because it is nice visually :blush:
More generally, a pipeline step transforms A into B which could be of a different type from A. Since the use of |> noreply() is the last step of the pipeline, it is more forgivable, even if it breaks the LiveView convention.
I just wanted to discuss the matter a little bit but I do not agree with incorporating that idea in Phoenix given the reasons you exposed.
As a side note, I’ve also used basic monadic code based on the idea of Railway Oriented Programming by Scott Wlaschin and a post on Medium. Stuff like:

defmacro left >>> right do
  quote do
    (fn ->
      case unquote(left) do
        {:ok, x}           -> x |> unquote(right)
        {:error, _} = expr -> expr
      end
    end).()
  end
end
1 Like