-
Notifications
You must be signed in to change notification settings - Fork 91
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
Shared event handlers #571
Conversation
@@ -124,10 +125,10 @@ defmodule Beacon.Loader.Page do | |||
end | |||
|
|||
defp handle_event(page) do | |||
%{site: site, event_handlers: event_handlers} = page | |||
event_handlers = Content.list_event_handlers(page.site) |
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.
There's still one step missing here :)
Whenever an event handler changes we'd need to broadcast a message to recompile all page modules so I'm wondering if it would be better to create a new EventHandler
module containing all handle_event
and on the handle_event
of PageLive
here
beacon/lib/beacon/web/live/page_live.ex
Lines 70 to 76 in ce916b5
result = | |
Beacon.apply_mfa( | |
page_module, | |
:handle_event, | |
[event_name, event_params, socket], | |
context: %{site: site, page_id: page_id, live_path: live_path} | |
) |
We just replace page_module
with event_handler_module
.
In this case whenever an event handler changes we only recompile the single event handler module and save resources by not duplicating the same event_handler on all page modules.
Wdyt?
now that's loaded in a separate module
Resolves #519