New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@actorize/core

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@actorize/core

Actorize helps building scalable js apps with a messaging system

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

@actorize/core

gzip size

Getting Started

$ npm install @actorize/core
# or
$ yarn add @actorize/core
import {
  createDirector,
  createStore,
} from '@actorize/core';

const director = createDirector({
  store: createStore(),
});

const actorOne = director.registerActor('one');
actorOne.onMessage((msgs) => {
  if (msgs[0].payload === 'DO_SOMETHING') {
    console.log('I DID SOMETHING');
  }
});

const actorTwo = director.registerActor('two');
actorTwo.sendMessage('one', 'DO_SOMETHING');

Plugin System

the most basic plugin is the logging plugin. This can be helpful to see when what actor send what.

import { createDirector, createStore, createLogPlugin } from '@actorize/core'

 // logs into 'debug' with "[ACTORIZE] ({{sender}}) => ({{recipient}}), {{payload}}"
const logPlugin = createLogPlugin()

// you have the option to filter too.
// this would only log messages from the actor named "ui"
// createLogPlugin({ filter: (msg) => msg.sender === 'ui'  })

const director = createDirector({
  store: createStore(),
  plugins: [logPlugin]
})

A plugin in general can be used to transform messages before they are saved to the store too. At the moment it just as options for onMessage which gets a Message and has to return a Message. The Typescript interface for the Plugin is

interface ActorizePlugin {
  onMessage?: (msg: Message) => Message,
}

Keywords

actor

FAQs

Package last updated on 04 Oct 2021

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