@im-sang-tae/vanilla
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

@im-sang-tae/vanilla - A Global State Management Library

@im-sang-tae/vanilla is a global state management library for JavaScript applications. It's designed to provide a simple and intuitive API for managing state in an efficient and scalable way.

Features

  • Supports both atom and selector for managing state.
  • Easy to integrate with any JavaScript application.
  • Efficient updates and minimal re-renders.
  • Support for tracking dependencies between selectors.

Installation

# using npm
npm install @im-sang-tae/vanilla

# using yarn
yarn add @im-sang-tae/vanilla

Usage

To start using IM_SANG_TAE in your project, you need to create atoms or selectors with an initial state:

import { createAtom } from "@im-sang-tae/vanilla";

// create atom
const myAtom = createAtom({
  key: "myAtom",
  initialState: 0,
});

// create selector
const mySelector = createAtom({
    key: "mySelector",
    get: ({get}) => {
        return get(myAtom) + 1;
    }
})

You can get the current state and set a new state using the atomState method from the state manager:

import { atomState, subscribe } from "@im-sang-tae/vanilla";

const [getMyAtom, setMyAtom] = atomState(myAtom);
const [getMySelector, setMySelector] = atomState(mySelector);

subscribe(myAtom, () => {
  console.log(getMyAtom());
});

subscribe(mySelector, () => {
  console.log(getMySelector());
});

License

This project is licensed under the MIT License.

Contribute

Contribute.

Package Sidebar

Install

npm i @im-sang-tae/vanilla

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

19.2 kB

Total Files

12

Last publish

Collaborators

  • pho9902
  • skmin