2.0.2 • Published 11 months ago

tarant-local-storage v2.0.2

Weekly downloads
2
License
MIT
Repository
github
Last release
11 months ago

logomakr_8pe69n

npm Build Status Coverage Status PRs Welcome issues Welcome npm GitHub issues GitHub pull requests Downloads

Motivation

Usually complex applications need to store offline part of the state, so it can be synced back or reused later. This module lets tarant store your actors serialized in the local storage and recovered implicitly.

Installation

Add it to your project using npm install tarant-local-storage --save or yarn add tarant-local-storage

Usage

You need to mark which classes need to be exported first. Usually this is done with the LocalStoragePersisted
class decorator.

import { Actor } from "tarant";
import { LocalStoragePersisted } from "tarant-local-storage";

export default class MyPersistedActor extends Actor {
    ...
}
LocalStoragePersisted("MyPersistedActor", MyPersistedActor) // NameOfThePersistedClass (unique), Class constructor

And then add the repository as a materializer and as a resolver:

import { ActorSystem, ActorSystemConfigurationBuilder } from 'tarant'
import MyPersistedActor from './actor';
import { LocalStoragePersisted, LocalStorageRepository } from 'tarant-local-storage';

window.onload = () => {
  const repository = new LocalStorageRepository()

  const system = ActorSystem.for(ActorSystemConfigurationBuilder.define()
  .withMaterializers([repository])
  .withResolvers([repository])
  .done())  

  system.actorOf(MyPersistedActor)
}
Created my free logo at LogoMakr.com
2.0.2

11 months ago

2.0.1

1 year ago

2.0.0

1 year ago

1.2.3

2 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago