drozdzynski

drozdzynski

Storex - Frontend store with the state on the backend

Storex is a frontend store with state management handled on the backend. It allows you to update the store state both from the frontend and backend, with all communication occurring over WebSocket.

More info available on Github.

Why Storex?

Features

  • Efficient state management: Only the differences (diffs) in the store state are sent with each mutation, minimizing data transfer.

  • Real-time updates: State changes are immediately reflected across all connected clients via WebSocket communication.

  • Backend-driven state: Storex allows both the frontend and backend to update the store state seamlessly.

  • Lightweight and fast: Designed for minimal overhead, ensuring rapid state updates and communication.

Key Differences from Phoenix LiveView

Phoenix LiveView is a powerful tool for building rich, interactive web applications without writing custom JavaScript. However, as your application grows, managing complex client-side state across multiple LiveViews or components can become challenging. This is where Storex comes in.

  • Client-Side State Management: While Phoenix LiveView handles server-side rendering and event handling, Storex focuses on managing state on the client side. It allows you to keep your client-side state in sync with the server, but with more flexibility in how that state is stored, updated, and accessed.

  • Decoupled State Logic: Storex decouples state management from the LiveView itself, enabling you to manage state across multiple components or even across the entire application. This contrasts with LiveView, where state is typically tied to a specific LiveView process.

  • Predictable State Updates: Storex follows a predictable, unidirectional data flow similar to Redux. This makes it easier to reason about state changes and debug issues, especially in complex applications.

  • Extensibility: Storex is designed to be highly extensible, allowing you to integrate it with other tools and libraries in the Elixir ecosystem. You can also define custom middleware to handle side effects, logging, or other tasks.

For an overview of Storex in action, check out the example provided here.

Most Liked

drozdzynski

drozdzynski

Hello,

I want to announce that stex was renamed to storex and published to hex.pm with version 0.1.0.

Changelog:

  • The only diff of the store state is being sent on each mutation.
  • Subscriber of connection status
  • Fixes in library

Links:

al2o3cr

al2o3cr

@drozdzynski FYI, I noticed the title of the thread was out-of-sync with the new name and adjusted it.

drozdzynski

drozdzynski

Version 0.2.4 released

Changelog:

  • Fix root state update
  • Remove optional from jason dependency
Sebb

Sebb

Bumped my examples repo.

drozdzynski

drozdzynski

I designed it as a replacement for frontend stores.
If you want to use it with SolidJS you can use from function to display the current state.

Example:

import { render } from "solid-js/web";
import { from } from "solid-js";
import Storex from "storex";

const store = new Storex({
  store: "App.RandomNumber",
  params: {},
});

function RandomNumber() {
  const state = from(store);

  return (
    <button onClick={() => store.commit("change", Math.random())}>
      {state()}
    </button>
  );
}

render(() => <RandomNumber />, document.getElementById("app")!);

Where Next?

Popular in Libraries Top

wmnnd
Hi there, for my project DBLSQD, I needed a file storage solution that is a bit more flexible than Arc. Because I thought others might f...
New
Azolo
Hey everyone, I just released WebSockex which is a Elixir WebSocket client. WebSockex strives to work as a OTP special process, be RFC6...
New
Eiji
ExApi is a library that I’m developing now and hope release soon This library will allow to: list all apis list all api implementation...
New
cjen07
parameterized pipe in elixir: |n&gt; edit: negative index in |n&gt; and mixed usage with |&gt; are supported example: use ParamP...
New
vic
Expat is a tiny experiment I did for extracting patterns and being able to reuse them (compose and share patterns between elixir librarie...
New
hpopp
After just over two years in development, this latest version of Pigeon is what I finally consider done in regards to my original vision ...
New
kelvinst
Hey everyone! Well, we made this lib a while ago and now we decided to finally go out and public with it! It’s a tool for creating and m...
New
mattludwigs
Grizzly is a library for working with Z-Wave devices. Z-Wave is a low-frequency radio protocol for controlling smart home devices on a me...
New
KallDrexx
For a good number of months I've been working on creating a very basic RTMP live video streaming server. Now that I have a very, very ba...
New
bluzky
You may know https://ui.shadcn.com/, a UI component library for React. I really love it’s design style and components. I’ve built some co...
381 12391 119
New

Other popular topics Top

JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35421 110
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New

Sub Categories:

We're in Beta

About us Mission Statement