1.0.4 • Published 2 years ago

tarant-sync-client v1.0.4

Weekly downloads
2
License
MIT
Repository
github
Last release
2 years ago

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

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

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.3.71

2 years ago

0.3.70

2 years ago

1.0.3

2 years ago

0.3.64

2 years ago

0.3.63

2 years ago

0.3.62

2 years ago

0.3.61

2 years ago

0.3.69

2 years ago

0.3.68

2 years ago

0.3.67

2 years ago

0.3.66

2 years ago

0.3.65

2 years ago

0.3.60

3 years ago

0.3.53

3 years ago

0.3.52

3 years ago

0.3.51

3 years ago

0.3.50

3 years ago

0.3.59

3 years ago

0.3.58

3 years ago

0.3.57

3 years ago

0.3.56

3 years ago

0.3.55

3 years ago

0.3.54

3 years ago

0.3.49

3 years ago

0.3.48

3 years ago

0.3.47

3 years ago

0.3.46

3 years ago

0.3.45

3 years ago

0.3.44

3 years ago

0.3.43

3 years ago

0.3.39

3 years ago

0.3.42

3 years ago

0.3.41

3 years ago

0.3.40

3 years ago

0.3.38

5 years ago

0.3.37

5 years ago

0.3.36

5 years ago

0.3.35

5 years ago

0.3.34

5 years ago

0.3.33

5 years ago

0.3.32

5 years ago

0.3.31

5 years ago

0.3.30

5 years ago

0.3.29

5 years ago

0.3.28

5 years ago

0.3.27

5 years ago

0.3.26

5 years ago

0.3.25

5 years ago

0.3.24

5 years ago

0.3.23

5 years ago

0.3.22

5 years ago

0.3.21

5 years ago

0.3.20

5 years ago

0.3.19

5 years ago

0.3.17

5 years ago

0.3.16

5 years ago

0.3.15

5 years ago

0.3.9

5 years ago

0.3.8

6 years ago

0.3.7

6 years ago

0.3.6

6 years ago

0.3.5

6 years ago

0.3.4

6 years ago

0.3.3

6 years ago

0.3.2

6 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.0

7 years ago