krezicoder

krezicoder

Support for Realtime - Server Side Updates and Streams like LiveView and PhoenixSync

Hi @bartblast I am super excited to use Hologram and started building my application in Hologram.

For pages that I dont need realtime updates, I am able to use Holograms but for ones that need realtime updates i am unable to use hologram am I missing something here.

Is there support for Realtime serverside updates like LiveView Updates, Phoenix Sync and support for Live Data Streams from Server side like in LiveView ?

Use-case for live chat applications and live dashboards update.

If the support isnt there yet what would you suggest for such usecases ?

Marked As Solved

garrison

garrison

PhoenixSync is built on top of ElectricSQL, which parses the Postgres WAL and streams subsets out to clients. You can use the Electric client directly to stream updates. I don’t know Hologram’s APIs well but I believe there is some way to push those updates down to the client. Then you can materialize the view yourself client-side.

There are also some (me) working on databases that natively support partitioned WAL streaming, so that will be an option someday!

Also Liked

bartblast

bartblast

Creator of Hologram

Hi @krezicoder!
Great to hear you’re building with Hologram!

You’re not missing anything - currently, data from the server can only be sent in response to commands. Server-initiated updates aren’t supported yet, but there are two features on the roadmap that directly address your use cases:

  1. Server-Triggered Actions - Enable triggering actions from server code outside of commands, such as background jobs (e.g. Oban) or scheduled tasks.
  2. Local-First Support - Implement local-first architecture with offline-capable local database, auto-sync, and conflict resolution for resilient applications.

Initially I planned to provide a PubSub API, but after deep exploration and Time to Implement Pub/Sub in Hologram - Looking for Your Input!, I shifted toward a local-first auto-sync approach - along the lines that @garrison advocated in that thread. The key insight: using PubSub for data sync forces you to manually wire up message passing and maintain synchronization yourself. This leads to bugs and tangled imperative synchronization code. A local-first layer gives you declarative, automatic sync - data just appears in your components when it changes, no manual routing needed. You want top-down data flow from a central source of truth, not component-to-component messaging.

We’d still have Server-Triggered Actions for ephemeral events (notifications, typing indicators) where they make sense - playing a role similar to cast (fire-and-forget, no delivery guarantee).

The local-first space is enormous and I’ve been analyzing it for some time, hence the silence on this topic.

What you can do today

With some creativity, you can support your use cases now with a combination of these:

  • Polling command - a command that periodically checks for updates from the server using the delayed param
  • Phoenix Channel alongside Hologram - store channel events in a global JS object, then read from it via Hologram.JS.exec/1 in a polling action
  • Hologram.JS.exec/1 for general but basic JS interop

The polling is needed because proper JS interop (Time for Hologram <> JavaScript Interop - What Would You Like to See?) hasn’t been implemented yet.

Hope this helps!

garrison

garrison

Sync is not trivial; there are certain guarantees the database has to be able to make.

In addition to ElectricSQL (for Postgres) there is also @jstimps 's work on EctoFDB Sync, and then there’s my work on Hobbes which is more foundational (implementing a DB from scratch).

I would suggest @bartblast try to come up with a design that is general enough to support any backend, but that may actually be somewhat difficult. For example, Postgres can be incrementalized (ElectricSQL does this with WAL parsing) but FoundationDB on the other hand cannot. This concern leaks into the framework layer because if Hologram runs on the client you want to maintain the view on the client, so it can’t be oblivious.

My hope is that Hobbes can provide an Elixir-native database primitive here (with proper incremental support) so that framework designers like Bart do not have to worry about database correctness stuff (which can get pretty in-the-weeds I’m afraid). I am making good progress on that front. Soon!

nxy7

nxy7

I think that no matter what there will be need for some sync/realtime communication primitive not involving DB because otherwise you’d not be able to work with big part of the ecosystem (like Presence) and existing tech.
Even if this primitive would not give as many capabilities as some ‘blessed’ solution (like some nice DB integration) right?
Because otherwise we’d be saving things to DB just to get sync and not persistance. I’ve seen some of your posts and know that very likely You have this thought out better than me so I’ll ask - do you think that with good enough DB solution (maybe something built on top of Hobbes that you’re developing) it would be practical to push everything you want to sync into DB? Presence / cursor positions / realtime stock prices etc etc.
All of those are very simple data (not derived data or some aggregates), so some solution that would just be synchronizing state kept on the server with client would suffice but as you’ve said my intuition is heavily influenced by RDBMS so I might have completely wrong idea about it and maybe DB might be a good place for ephermal data too.

Where Next?

Popular in Questions Top

Kurisu
For example for a current url like http://localhost:4000/cosmetic/products?_utf8=✓&amp;query=perfume&amp;page=2, I would like to get: ...
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
vac
Hi, I’m quite new in Elixir and I’m trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and I...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
beno
I will often find my self writing things similar to: case some_value do nil -&gt; something() "" -&gt; something() _ -&gt; somethi...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New

Other popular topics Top

9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
johnnyicon
Hi all, I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I’m trying to use Postgres...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

We're in Beta

About us Mission Statement