revati
Hello, currently, to call send_update, i have to pass destination module and id (which is more of an html id than elixir side id - at least how i interpret it).
If i have live_component nested in another live component i do this currently
# Parent
<.live_component
module={ChildComponent}
id={"#{id}-child"}
parent={{__MODULE__, id}}
/>
# Child
def handle_event("...", _, socket) do
{parent_module, parent_id} = socket.assigns.parent
send_update(parent_module, id: parent_id, action: my_payload)
end
I looked under the hood and all parent_module, id: parent_id does is gets cid to call further call correct callback (found by cid).
Wouldn’t it be easier just to
# Parent
<.live_component
module={ChildComponent}
parent={@myself}
/>
# Child
def handle_event("...", _, socket) do
send_update(socket.assigns.parent, action: my_payload)
end
- if no id is given cid is used as id
- both live views and live components have cid
- cid can be used to call send_update to any target (both live views and live components).
- live views might aswell have update callback to handle those cases.
This also would move towards implementing this this:Provide a unified mechanism to message the parent/child · Issue #1597 · phoenixframework/phoenix_live_view · GitHub
Trending in Proposals: Ideas
We are seeing a lot of warning logs like this:
navigate event to "https://someurl" failed because you are redirecting across live_sessio...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixirconf-us
- #elixir-ls
- #ai
- #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)
atomkirk
Yes please! A case where i needed this was an autosuggest component. Arrow keys move slection up and down list of options, enter should select it and tell the parent. Theres no way to send a message to the parent programmatically!
trisolaran
You might find inspiration on how to do that here: GitHub - maxmarcon/live_select: Dynamic (multi)selection field for LiveView · GitHub
TL;DR: to send an event to the parent you can use a hook. Yes, not ideal, because you go through the frontend, and yes, a way to be able to message the parent with a unified API is IMO very much needed.