@machinat/dev-state
TypeScript icon, indicating that this package has built-in type declarations

0.5.0-beta.30 • Public • Published

Dev State Module

This module implement the BaseStateController with in-memory and file storage. We suggest to use them for testing purpose only.

Install

npm install @machinat/core @machinat/dev-state
# or with yarn
yarn add @machinat/core @machinat/dev-state

Docs

Check the Using State document for the usage guide, and the package reference for API details.

Setup

In-Memory State

import Machinat from '@machinat/core';
import { InMemoryState } from '@machinat/dev-state';

const app = Machinat.createApp({
  modules: [
    InMemoryState.initModule(),
  ],
});

File State

import Machinat from '@machinat/core';
import { FileState } from '@machinat/dev-state';
import YAML from 'yaml';

const app = Machinat.createApp({
  modules: [
    FileState.initModule({
      path: './.state_storage.json',
    }),
  ],
  services: [
    // you can swap the serializer
    { provide: FileState.Serializer, withValue: YAML }
  ],
});

Readme

Keywords

none

Package Sidebar

Install

npm i @machinat/dev-state

Weekly Downloads

0

Version

0.5.0-beta.30

License

MIT

Unpacked Size

46.7 kB

Total Files

30

Last publish

Collaborators

  • lrills0515
  • lrills