DEV Community

Cover image for Leave Redux for a few moment and Try GX 😍😍
Dilane3
Dilane3

Posted on

Leave Redux for a few moment and Try GX 😍😍

What's GX ?

GX is Javascript library used to manage global state within a React and React Native applications like Redux and other do.

It's a Lightweight, very Performant and Easy to use library for managing state 😍.

More about GX.

GX is my library that I released on febuary (the first version) and I'm so happy for that archievement. I used it now in all my personal projects and it's well integrated into React environment (React Native, NextJs). With less configuration you can state working 😁😁

How it works ?

Well, there is some concepts that you have to know to be able to use this library.

Signal

A signal is just a particular state that can contains one resources such as products, users, current user and so on. So If you want to create a global state to save for example a list of products, you have to create a signal.

Example

Image description

In this example I create a signal to save a counter value, that can be incremented and decremented by calling actions which are defined in the actions property of the object parameter of the createSignal function.

Store

A store is the place where you have to register all your signal in order to make them available from anywhere in your application.

Example

Image description

Set the Provider

GX comes with a provider which is used to make the store accessible from anywhere in your application.

Example

Image description

Usage

Now, as the library is correctly set up, we can now consume our state (the counter value) and act to it by incrementing or decrementing its value.

Example

Image description

So easy to use 🀩🀩

Next step

You can learn more by visiting the website documentation of the npm readme.

Documentation: https://gx.dilane3.com
NPM Readme: https://www.npmjs.com/package/@dilane3/gx

The project is open source, so that you can suggest your impovement and make the libray grow with time 😊😊

Github Repo: https://github.com/react-gx/gx

Top comments (2)

Collapse
 
sathis810 profile image
Sathish Kumar

Similar to zustand?

Collapse
 
dilane3 profile image
Dilane3 • Edited

I don't know how zustand works, I created this Library by basing myself on my experience with Context API and Redux.

But it does the same thing like Zustand but not in the same way, I suppose.