Hi,
Working on an experimental marriage between LiveView and a front-end JS library called Webix. For this, I am trying to pass an additional parameter (_access_token
) to the server on liveConnect.connect()
, for further processing during mount/3
(using get_connect_params(socket)
) . This works fine the first time, but on subsequent ‘mounts’ the only params that is retained is csrf_token
, and my _access_token
param gets reset to nil
.
app.js:
let liveSocket = new LiveSocket("/live", Socket,
{params: {_csrf_token: csrfToken, _access_token: accessToken},
hooks: {app: appHook}})
liveSocket.connect()
app_live.ex:
#inside def mount/3 - first time
get_connect_params(socket) #=> %{"_access_token" => "123", "_csrf_token" => "XYZ"}
#inside def mount/3 - second time and beyond
get_connect_params(socket) #=> %{"_access_token" => nil, "_csrf_token" => "XYZ"}
Is there some special reason why it works like this? Why does only some info get retained? Or maybe I should discard the LiveView overhead and just work with websockets directly (I sure do love bypassing the whole JSON API layer).