New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@allgemein/eventbus-dev

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@allgemein/eventbus-dev

  • 0.14.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

@allgemein/eventbus

Build Status codecov Dependency Status

Usage

import 'reflect-metadata'
import {Event,EventBus,subscribe} from '@allgemein/eventbus'

// Definition of the exchange object type
@Event()
class MySuggestion {
    content:string;
    constructor(content:string){
      this.content = content;
    }
}

// subscribe to listening for the explicit object type
class WillListenOnEvent {

  @subscribe(MySuggestion)
  letstalk(data:MySuggestion){
    console.log(data.content);
  }
}

let instance = new WillListenOnEvent()
EventBus.register(instance);


let suggestion = new MySuggestion('blabla');
EventBus.post(suggestion);

// That's it

Use without annotations:

import 'reflect-metadata'
import {Event, subscribe, EventBus, EventBusMeta} from '@allgemein/eventbus'

// Definition of the exchange object type
class MySuggestion {
    content:string;
    constructor(content:string){
      this.content = content;
    }
}

// subscribe to listening for the explicit object type
class WillListenOnEvent {

  letstalk(data:MySuggestion){
    console.log(data.content);
  }
}

EventBusMeta.$().register({
  type: 'subscribe',
  target: WillListenOnEvent,
  eventClass: MySuggestion,
  methodName: 'letstalk',
  configuration: 'default',
  configurationOptions: null
});

let instance = new WillListenOnEvent()
EventBus.register(instance);

let suggestion = new MySuggestion('blabla');
EventBus.post(suggestion);

Supported adapter

  • default (Eventemitter)
  • nsq
  • redis

Configuration

TODO

Example configuration for nsq:

import {EventBus} from '@allgemein/eventbus'

let eventBusSettings = {
  name: 'default_nsq',
  adapter: 'nsq',
  extra: {
    reader: {
      nsqdTCPAddresses:['localhost:4150'],
      maxInFlight: 100,
      messageTimeout: 30000
    },
    writer:{
      host: '127.0.0.1',
      port: 4150
    }
  }
}

EventBus.$().addConfiguration(eventBusSettings);

Example configuration for redis:

import {EventBus} from '@allgemein/eventbus'

let eventBusSettings = {
  name: 'default_redis',
  adapter: 'redis',
  extra: {
    host: '127.0.0.1',
    port: 6379
  }
}

EventBus.$().addConfiguration(eventBusSettings);

Keywords

FAQs

Package last updated on 17 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc