You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've heard from multiple people that using req.private and resp.private feels wrong because name private implies it is internal. The idea behind private was to follow Plug, https://hexdocs.pm/plug/Plug.Conn.html#module-private-fields. I wonder if, similarly to Plug, we should add assigns and it clearly will be meant to be used by users and will be familiar to Plug/LV users. Before:
which is of course not apples to apples comparison as the former uses a function call. That's the thing though, how should the function be called? If we'd have Req.Response.assign(resp, assigns) then naturally it could be called Req.Response.update_assign(resp, name, initial, fun). Another idea though is calling it just update, akin to Phoenix.Component.update/3:
The signature would be: Req.update(req_or_resp, key, initial, fun), that is, it works with both req.assigns and resp.assigns. I believe the biggest benefit of this is users of Req could stay within Req module and not care about underlying Req.Request and Req.Response modules. Req.Request and Req.Response private could still be used by step library authors. Or we deprecate it altogether in favor of assigns.
The text was updated successfully, but these errors were encountered:
I've heard from multiple people that using
req.private
andresp.private
feels wrong because name private implies it is internal. The idea behindprivate
was to follow Plug, https://hexdocs.pm/plug/Plug.Conn.html#module-private-fields. I wonder if, similarly to Plug, we should addassigns
and it clearly will be meant to be used by users and will be familiar to Plug/LV users. Before:after:
which is of course not apples to apples comparison as the former uses a function call. That's the thing though, how should the function be called? If we'd have
Req.Response.assign(resp, assigns)
then naturally it could be calledReq.Response.update_assign(resp, name, initial, fun)
. Another idea though is calling it justupdate
, akin toPhoenix.Component.update/3
:The signature would be:
Req.update(req_or_resp, key, initial, fun)
, that is, it works with both req.assigns and resp.assigns. I believe the biggest benefit of this is users of Req could stay withinReq
module and not care about underlyingReq.Request
andReq.Response
modules. Req.Request and Req.Response private could still be used by step library authors. Or we deprecate it altogether in favor of assigns.The text was updated successfully, but these errors were encountered: