I have a website running in production where some results are displayed based on some query params. These results are being pulled out of the assigns in the corresponding template of the liveview.
After a few minutes of inactivity in the site or after coming back to site after some time in mobile makes the results disappear. This also happens noticeably and immediately when the I disconnect from the internet and connect back again immediately afterwards.
What should I do so that the results are displayed even if there has been a connection error? My best guess on why this is happening is the assigns are being meddled with in some way and are disappearing due to some reason.
Any pointers on where I should be looking to fix this issue?
Do you create the results on the mount
or handle_params
of the liveview, or are they created elsewhere and attached (e.g. via handle_event
or handle_info
). When a liveview is disconnected (e.g. due to a connection error persisting longer than the timeout) the liveview process will be shut-down and all state will be lost. You have a few choices - either recreate the state on liveview mount
or handle_params
, hold the state in another, non-liveview process, or cache the state using something like cachex.
moving the code from the handle_info
block directly into the mount
solved the problem. Thanks for the help