mortenlund
Hi!
To make it easier to develop LiveComponents that require information from the current context of the LiveView it would be awesome if the LiveComponent.mount/1 could receive the assigns from the LiveView that contains the component.
A real-world example is the need to get the current_user that one may store in the assigns of the LiveView
Alternative could be to add a second mount/2 where the second argument is the parent socket or assigns
I know that you can give this as arguments when using <.live_component module={MyLiveComponent} id="myid" current_user={@current_user} /> and this will be params to the update/2 function in the component.
But sometimes you would like to load some assigns in the component only once and not everytime the page has updates that then triggers the update/2 function in the component
Trending in Proposals: Ideas
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixir-ls
- #ai
- #elixirconf-us
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 2- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
LostKobrakai
You can compare what is stored in
socket.assignswith the data privided by theassignsparameter ofupdate/2to figure out if you want to rerun some calculation or not.mortenlund
Yes this is what I currently do

Would just be intuitive if you could think of
mountas “setup” function and then only supply contextual changes to the component using theupdatefunction