Problem description
Currently, the event_mapping/0 callback is an arguably inconvenient way to map handle_event event names to Permit action names.
We would like to explore more convenient alternatives that allow the developer to keep the mapping closer to the event handler definition itself, for better code readability.
Proposed solution
A combination of private and public module attributes controlled using a before_compile callback could be used to facilitate the new method of mapping, while at the same time preserving backwards compatibility.
Alternatives considered
No response
Use case
Implementing LiveViews with events authorized using Permit.Phoenix.LiveView.
Desired API/code example
@permit_action :update
def handle_event("save", %{"article" => article_params}, socket) do
article = socket.assigns.loaded_resource
# ...
end
Component
LiveView
Priority (1-3)
3 - High - Blocking my work
Additional Context
No response
Checklist
Problem description
Currently, the
event_mapping/0callback is an arguably inconvenient way to maphandle_eventevent names to Permit action names.We would like to explore more convenient alternatives that allow the developer to keep the mapping closer to the event handler definition itself, for better code readability.
Proposed solution
A combination of private and public module attributes controlled using a
before_compilecallback could be used to facilitate the new method of mapping, while at the same time preserving backwards compatibility.Alternatives considered
No response
Use case
Implementing LiveViews with events authorized using
Permit.Phoenix.LiveView.Desired API/code example
Component
LiveView
Priority (1-3)
3 - High - Blocking my work
Additional Context
No response
Checklist