Code Monkey home page Code Monkey logo

treble-gsm's Introduction

ย 

npm version example workflow

Treble Global State Management

Treble is a Hook-based global state management container and library for React.js apps. It is inspired by a blog post by Luke Hall. Treble's goal is to provide a simple way to manage global state in your React app by providing an easy setup, little boilerplate, and a straight forward API.

Getting Started

Install Treble

npm install treble-gsm

or

yarn add treble-gsm

Create Treble Store

Create a Store.js file in your app. Example below.

import { createStore } from 'treble-gsm';

const Store = createStore([
    {
        action: 'updatePokemon',
        state: { pokemon: 'Mewtwo' }
    },
    {
        action: 'updatePokemonGame',
        state: { pokemonGame: 'Pokemon Red' }
    }
],/* optional parameters */);

export default Store;

Treble Container Component

Import the Treble container component and Store.js into your App.js or index.js and wrap it around the components you wish to have access to your store. Pass the Store into the Treble store prop. Your app now has global state management!

import  React  from  'react';
import  Treble  from  'treble-gsm';
import  Store  from  './_store';

const App = () => {
    return (
        <Treble store={Store}>
            {/* Components */}
        </Treble>
    );
}

export  default  App;

For more documentation visit the official website, get-treble-gsm.com.

treble-gsm's People

Contributors

hjrdave avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

treble-gsm's Issues

Add middleware features

Need to do more research on the benefit of this.

create middleware Check, Convert, and Call features

Feature: Better History management

There is a history.prev and history.reset built into the library right now (not documented). I dont feel like it is as robust as it should be, so I am proposing a new api for it.

example:
const { fruit, cars } = useTrebleHistory( );

//access values by index

{ fruit[0] }

Create Hub feature

Create a Hub feature so stores can be broken up in larger apps for scalability.

Add scoped GSM

Add feature to allow for scoped GSM components in complex UI components.

Add callback feature to state store.

Would like to add a callback to state. Basically when ever the store is updated the specific state that is updated will do a callback function

Store action helper utility

Way to make Store actions more detectible when subscribing to the Store.

Possible api
const [StoreItems, StoreMethods, Utilities] = useTreble();

const { actions } = Utilities;

Store.update( actions.updateSomeState, 'foo );

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.