I believe it can be isolated to the exec_js call setup in page_loaded() so this is what I tried:
def page_loaded(socket) do
...
socket |> IO.inspect(label: "**SOCKET: ")
{status, return_value} = exec_js(socket, "navigator.geolocation.watchPosition(function(pos){debugger;Drab.exec_elixir('position_changed', {\"lat\":pos.coords.latitude, \"lon\": pos.coords.longitude, \"drab\": __drab.index});}, function(err){}, {});", timeout: 1000)
end
And in the first line of
defhandler position_changed(socket, payload) do
payload["drab"] |> IO.inspect(label: "__drab.index")
socket |> IO.inspect(label: "**SOCKET-0: ")
...
end
What I see is the socket is correct inside page_loaded, but not in the position_changed() handler. It seems good inside the browser as you can see from the passed in value that is printed payload[“drab”]
OUTPUT: inside page_loaded()
**SOCKET: : %Phoenix.Socket{
assigns: %{
__action: :index,
...
__drab_index: "gi2dqnbygazdenbv",
...
OUTPUT: Inside position_chaged() handler
__drab.index: "gi2dqnbygazdenbv"
**SOCKET-0: : %Phoenix.Socket{
assigns: %{
__action: :index,
...
__drab_index: nil,
...
Phoenix.Socket.assigns.__drab_index looks good initially inside page_loaded() and stays good until the first call to position_chaged(), when it is passed in the socket value as nil.
It seems that __drab.index is correct in the browser context, but not sure if there is a better way to test what you are asking. Let me know.






















