A tiny event-based state manager Storeon for Velo

Update: Jan 10, 2021. Package is renamed to storeon-velo from corvid-storeon

In the article “State management in Velo” Shahar Talmi bringing up a question about control app states in Velo.

The state of app it’s a really big problem. If you have a lot of components dependencies between each other or a lot of user interaction, eventually, add a new feature or support app is going through suffering.

In this article, I share my solution. It’s a very tiny library Storeon (core 180 bytes in gzip) with an easy interface. So I wrote a wrapper for integration with Velo. As a result, we have the state manager storeon-velo less than 90 lines of code.

  • Post on Blog

  • Live Demo

8 Likes

Awesome work!

corvid-storeon has been added to package manager

Great work!

I am trying to use this in my project, however I have a usage question. When I use the suggested method:

import { dispatch, connect, connectPage } from “public/store”;

Does this create a new store object everytime I import this in a new page or does only one store object exist with many references to it?

It creates a new store with function createStoreon([])

Yes, each time in a new page or lightbox it would create a new store. It’s a design of Wix “live cycle” pages code, it reloads a code after page navigation.

In my projects, I create a store per each page.