In my phoenix app, I am trying to load a bunch of data and make them accessible to my root template (across all pages). To my knowledge, this is done via assigns, but I don't know where to load it.
I think something like
use App.LiveView
use App.News
assign(socket, news: News.all)
should work, but I don't know where to put this code, so the socket would be available. Coming from Express.js, I'm looking to do something like:
router.use((req, res, next) => {
// Load news into global variable
// ...
next()
})
Thanks for helping.