Topical – Elixir library for synchronising state to web clients
Topical – Elixir library for synchronising state to web clients
Hi HN. I've been working on an Elixir library for synchronising state, maintained by the server, to connected web clients. I found this was something I kept implementing for side-projects, so I've extracted it into a library. It solves a similar problem to Phoenix LiveView, but aimed at a different level of abstraction: rather than synchronising HTML and UI events, this just synchronises (JSON-serialisable) state. Topics can be shared between connected users, and each client can subscribe to multiple topics. The library takes care of starting topic instances (GenServer processes) as needed, then shuts them down when they're no longer in use. A topic is defined with an initialisation function (which can be used to load the initial state and/or subscribe to updates from a database/etc), and can then respond to requests/notifications from clients, or arbitrary BEAM messages, to efficiently update (and synchronise) state. The library can be used directly from Elixir, or there's a Cowboy adapter that can be used along with the JavaScript client or React hook. I've put together a few very basic examples. Some use cases I think this works great for are, a) synchronising ephemeral state (e.g., cursor positions); b) as a layer over a database for synchronising real-time updates to persisted state. In particular, this works pretty well for event-sourcing-type scenarios - you can load events from the database, subscribe to updates, and (if needed) periodically take snapshots of the state. Please let me know what you think. https://github.com/joefreeman/topical
Share cardActual performance
Launch Intel predictions
Analyze your own launch →Correct prediction on native model
Similar products
Machinery – A State Machinery Library for Elixir (and Phoenix)
I made a state management library
Legend-State 1.0 – The fastest React state library
“Java Retrofit” for C++. Build Web Clients with Oatpp ApiClient/libcurl
Last System State Before OOM
ReSift – a React state management library for fetches
A small, functional state management library
Luciex – A small simplistic state management library
Vuex-light – state management library for Vue 3
1kb progressive state management library inspired by Vuex