I’ve been contributing to Hologram and building applications with it lately. It just hit a big milestone: v0.9 was recently released and includes real-time features (release post here if you want to read more). This release has unblocked me from building real applications with it. So, to learn the framework better, I put together a small project to test out how Hologram holds up in a real, albeit very small, project. The result is Holodeck.
It currently includes three applications:
Chat - Pick a name, create/join rooms, and chat. Messages are persisted and broadcast to everyone in the room over a Hologram subscription. Joining a room pulls the full room history.
Dashboard - A live look at the running BEAM: per-core CPU, memory breakdown, scheduler/uptime info, and the top processes (sortable by memory, reductions, or pid). It also streams the app’s logs into the page live.
Polls - Create a simple poll, vote, and watch the results update live. The results page also demos Hologram’s JS interop by working directly with Chart.js.
Keep in mind that I left a few things out on purpose, since I wanted to focus on Hologram and on keeping the app easy to pick up and use. So there’s no authentication in chat, a fixed number of answers in polls, and so on.
Feedback is welcome! If you know a better way to accomplish something, please let me know. And if there’s another part of Hologram you’d like to see demoed, say the word and I’ll see about building it. Contributions are welcome too.
I should have mentioned it in the original post, but I had the same issue on mobile. I haven’t been able to fully figure out why yet. When it, it was crashing on saving the username actually which is used for room creation. I believe it was claiming that crypto.randomUUID was not a function. Still need to dig a bit deeper on that one.
Unfortunately I have not seen this happen, but thanks for letting me know. I will see if I can replicate and get it fixed. When you saw this, did you see it from different browsers / tabs? Or is this something that you were seeing from just a single tab and not seeing the message from the client that sent it?
Are you on mobile? Because that is unfortunately known at the moment that some things weren’t working there.
I just ran through everything about 30m ago and it was all working for me. If you are able to be more specific about what is broken and in what environment, it would be appreciated so that I am able to fix it.
If you open the browser console there are a few errors (a FunctionClauseError among them) that I suspect are behind the funky behaviour, so that’s probably where I’d start. (Happy to help if you get stuck)
One separate note: the broadcasting goes through Hologram.Realtime.* directly, which is meant more as an escape hatch. For chat it’s better to use put_broadcast from inside a handler - it’s transactional, so the send is tied to the handler succeeding. It’s usually a small change too: if whatever does the broadcast is reachable from a handler that carries the server struct (like init/3 or command/3), you just thread that server struct down to it and call put_broadcast there.
fwiw, I see the same occasionally. Sometimes they appear just fine, albeit a bit delayed (not sure where the app is hosted it but I’m in Texas). Not sure what the underlying issue is. The only error I see in the console is:
[Error] Failed to save page snapshot to OPFS:
TypeError: (await(await navigator.storage.getDirectory()).getFileHandle(i,{create:!0})).createWritable is not a function. (In '(await(await navigator.storage.getDirectory()).getFileHandle(i,{create:!0})).createWritable()', '(await(await navigator.storage.getDirectory()).getFileHandle(i,{create:!0})).createWritable' is undefined)
(anonymous function) — hologram.mjs:1148
(anonymous function) (runtime-8412d975c288bc78de41778d48ee78f0.js:45:16273)