larshei

larshei

What I want to achieve

I am currently building a small frontend displaying a JavaScript based map, with markers for positions of assets. The map itself is a Component.

There are basically just two pages:

  1. An overview page listing all assets
  2. A detail page per asset.

I can update the map using push_event/3, what works well on the details page:
There are two events, add_asset and update_asset.
On mounting the liveview, the asset is added to the map.
When new data comes (in my case in a handle_info), the asset position is updated.

I would like to add a map to the overview page, listing all assets positions.

What I tried to achieve this

As there already is a function to add an assets position to the map, I thought I’d just use that.
The overview page renders a bunch of Components, of which one is the map.
The other components are simply list entries, one per asset. All components are stateless.
I tried to push_event/3 an add_asset event from each components update() callback.

Expected behaviour
I would have expected each asset to be added to the map.

Actual behaviour
Nothing is added.
Each attempt to add an asset should trigger a console.log(), but nothing is logged.

Question
Seems like the events are never actually pushed out to browser.
Does pushing events from within a components update() function not work?
Or maybe, do these occur before the socket connection is established?

Showing Posts 1 to 1

tomkonidas

tomkonidas

When you push_event/3 your are pushing an event to the client to be consumed by hooks. So you would have to have a JS hook that would catch that event to send back to the backend.

Are these 2 pages different live views? (i.e. Listing.Index and Listing.Show)

Are you mounting the live_component in each view?

Can you paste some code so we can maybe see a little whats going on?

Your JS hooks, LiveView(s) and your component would be sufficient

— All posts loaded —

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
Blokh
Hey guys, I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly Do you guys have any suggestions what is the best prac...
New
roeland
Kia ora, We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
Onor.io
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
jaybe78
Hello, I’m developing a online persistent chat system (what’s app) like using elixir/dynamodb/aws for a mobile app(flutter). The diffic...
New
Trolleger
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New

Other Trending Topics Top

garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
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
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews