@agmajs/store

State Management for Agmajs.

Usage no npm install needed!

<script type="module">
  import agmajsStore from 'https://cdn.skypack.dev/@agmajs/store';
</script>

README

@agmajs/store

State management for @agmajs/script.

Installation

Using NPM:

$ npm install @agmajs/store

Using Yarn:

$ yarn add @agmajs/store

Usage

Creating the Store

It's best to create a separate folder called store and have an index.js in there with the following code.

// store/index.js
const { createStore } = require("@agmajs/store");

module.exports = createStore('nameOfTheLocalStorage', {
  // Your default store state here...
});

Using the Store

// commands/test.js
const { defineCommand } = require("@agmajs/script");

const store = require('../store');

module.exports = defineCommand({
  name: "test",
  run: (script, chatCtx, args) => {
    store.state.test = false;
  }
});