Skip to content

Commit

Permalink
s/connected/attached
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismccord committed Feb 28, 2024
1 parent d7039e4 commit 80e6b5d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions README.md
Expand Up @@ -37,10 +37,10 @@ config :my_app, MyAppWeb.Endpoint,
]
```

Next, you'll need to listen for the `"phx:live_reload:connected"` event and enable client logging by calling the reloader's `enableServerLogs()` function, for example:
Next, you'll need to listen for the `"phx:live_reload:attached"` event and enable client logging by calling the reloader's `enableServerLogs()` function, for example:

```javascript
window.addEventListener("phx:live_reload:connected", ({detail: reloader}) => {
window.addEventListener("phx:live_reload:attached", ({detail: reloader}) => {
// enable server log streaming to client.
// disable with reloader.disableServerLogs()
reloader.enableServerLogs()
Expand All @@ -55,10 +55,10 @@ Many times it's useful to inspect the HTML DOM tree to find where markup is bein
export PLUG_EDITOR="vscode://file/__FILE__:__LINE__"
```

The `vscode://` protocol URL will open vscode with placeholders of `__FILE__:__LINE__` substited at runtime. Check your editor's documentation on protocol URL support. To open your configured editor URL when an element is clicked, say with alt-click, you can wire up an event listener within your `"phx:live_reload:connected"` callback and make use of the reloader's `openEditorAtCaller` and `openEditorAtDef` functions, passing the event target as the DOM node to reference for HEEx file:line annotation information. For example:
The `vscode://` protocol URL will open vscode with placeholders of `__FILE__:__LINE__` substited at runtime. Check your editor's documentation on protocol URL support. To open your configured editor URL when an element is clicked, say with alt-click, you can wire up an event listener within your `"phx:live_reload:attached"` callback and make use of the reloader's `openEditorAtCaller` and `openEditorAtDef` functions, passing the event target as the DOM node to reference for HEEx file:line annotation information. For example:

```javascript
window.addEventListener("phx:live_reload:connected", ({detail: reloader}) => {
window.addEventListener("phx:live_reload:attached", ({detail: reloader}) => {
// Enable server log streaming to client. Disable with reloader.disableServerLogs()
reloader.enableServerLogs()

Expand Down
2 changes: 1 addition & 1 deletion priv/static/phoenix_live_reload.js
Expand Up @@ -121,7 +121,7 @@ class LiveReloader {
}

dispatchConnected(){
parent.dispatchEvent(new CustomEvent("phx:live_reload:connected", {detail: this}))
parent.dispatchEvent(new CustomEvent("phx:live_reload:attached", {detail: this}))
}

log(level, str){
Expand Down

0 comments on commit 80e6b5d

Please sign in to comment.