Socket
Book a DemoInstallSign in
Socket

tarant-sync-client

Package Overview
Dependencies
Maintainers
2
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tarant-sync-client

remote-sync client resolver and materializer for the tarant framework

latest
Source
npmnpm
Version
1.0.4
Version published
Maintainers
2
Created
Source

logomakr_6v3wpd

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

Motivation

Provide the capabilities to actors to synchronize with a backend.

Installation

add it to your project using npm install tarant-sync-client --save or yarn add tarant-sync-client

Usage

Initialize the sync client with the configuration you desire and add it to your actor system as both a materializer and a resolver


import { RemoteResolverMaterializer } from "tarant-sync-client";
import AppActor from '../AppActor';

const config : any  = {
    sync: {
        active: true,
        delay: 1000
    },
      paths: {
          pull: "/pull", 
          push: "/push", 
      },
      actorTypes: { AppActor }
}

const remote = new RemoteResolverMaterializer(config)
const system = ActorSystem.for(ActorSystemConfigurationBuilder.define()
.withMaterializers([remote])
.withResolvers([remote])
.done()) 

your actors will require to implement IUpdatable (UpdateFrom) and IExportable (toJson)

import { Actor } from "tarant";
import { IUpdatable, IExportable } from "tarant-sync-client"

export default class AppActor extends Actor implements IUpdatable, IExportable {

  constructor(name: string) {
      super(name)
  }

  addOne() {
      this.counter++
  }

  toJson(){
        return {
            id: this.id,
            type:"AppActor",
            counter: this.counter
        }
    }

    updateFrom({ counter }: any): void {
        this.counter = counter
    }

    private counter = 1; 
}

confiuration options

  • sync.active: boolean value defining if there should be live updates pull from the backend
  • sync.delay: period of time in miliseconds between updates from the backend
  • paths.pull: path to endpoint for pulling data from the backend
  • paths.push: path to endpoint for pushing data to the backend
  • ActorTypes: objects registering the type of actors that should be sync with the backend
Created my free logo at LogoMakr.com

Keywords

actor system

FAQs

Package last updated on 12 Jun 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.