Local 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/local-state
yarn add @machinat/core @machinat/local-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/local-state';
const app = Machinat.createApp({
modules: [
InMemoryState.initModule(),
],
});
In-Memory State
import Machinat from '@machinat/core';
import { FileState } from '@machinat/local-state';
import YAML from 'yaml';
const app = Machinat.createApp({
modules: [
FileState.initModule({
path: './.state_storage.json',
}),
],
services: [
{ provide: FileState.Serializer, withValue: YAML }
],
});