Migrate from channel to phoenix live view.
Move phoenix config to ui project. Sync progress on page load.
This commit is contained in:
parent
e888f1330b
commit
ad24ec96ac
26 changed files with 120 additions and 164 deletions
|
@ -11,7 +11,8 @@ import css from "../css/app.css"
|
|||
//
|
||||
import "phoenix_html"
|
||||
|
||||
// Import local files
|
||||
//
|
||||
// Local files can be imported directly using relative paths, for example:
|
||||
import socket from "./socket"
|
||||
import {Socket} from "phoenix"
|
||||
import LiveSocket from "phoenix_live_view"
|
||||
|
||||
let liveSocket = new LiveSocket("/live", Socket)
|
||||
liveSocket.connect()
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
import {Socket} from "phoenix"
|
||||
|
||||
let socket = new Socket("/socket", {params: {token: window.userToken}})
|
||||
|
||||
socket.connect()
|
||||
|
||||
let channel = socket.channel("morse:progress", {})
|
||||
channel.join()
|
||||
.receive("ok", resp => { console.log("Joined successfully", resp) })
|
||||
.receive("error", resp => { console.log("Unable to join", resp) })
|
||||
|
||||
let progressBar = document.getElementById("morse-progress")
|
||||
|
||||
channel.on("update", (content) => {
|
||||
progressBar.value = content["value"]
|
||||
progressBar.innerHTML = content["value"]
|
||||
});
|
||||
|
||||
export default socket
|
Loading…
Add table
Add a link
Reference in a new issue