Skip to content

Add support for user-defined client JS hooks #284

@leandrocp

Description

@leandrocp

Allow users to pass https://hexdocs.pm/phoenix_live_view/js-interop.html#client-hooks-via-phx-hook to the Beacon livesocket.

The socket is initialized at

let liveSocket = new LiveView.LiveSocket(socketPath, Phoenix.Socket, { params: { _csrf_token: csrfToken } })
and note it does reuse the LiveView object from the host app and connects to the same socket path. It's important to reuse the same JS client version to avoid misbehavior.

Ideally the hook code should be stored in the DB and changed at runtime in the admin interface but that imposes some challenges on how to inject the js hook code into the socket.

Metadata

Metadata

Assignees

Labels

area:loaderRelated to app and resource loadingenhancementNew feature or improvementproposalIdea in research phaseroadmapPriority issues that will be released in the short term

Type

No type

Projects

Status

Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions