🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

@ebay/oja-pubsub

Package Overview
Dependencies
Maintainers
13
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ebay/oja-pubsub

Organizing actions into pubblishers and subscribers

Source
npmnpm
Version
2.0.2
Version published
Weekly downloads
1
-50%
Maintainers
13
Weekly downloads
 
Created
Source

oja-pubsub

Downloads

This module is a subset of eBay Oja framework.

The module defines generic actions that can be used to organize actions into publishers and subscribers that are completely disconnected from each others.

Installation

$ npm install @ebay/oja-pubsub --save

Actions

  • action('oja/subscribe', 'topic', listener) - subscribe to the event
  • action('oja/unsubscribe', 'topic', listener) - unsubscribe from the event
  • action(oja/dispatch, 'topic', eventData) - dispatch event to the subscribers

Listener

function (eventType, ...eventData) {}

Usage

  • Subscribing to the event:
const { createContext } = require('@ebay/oja-action');
const context = await createContext();
// subscribe
const listener = await context.action('oja/subscribe', 'topic', (eventType, eventData) => {
    console.log(eventData);
});
  • Dispatching an event:
await context.action('oja/dispatch', 'topic', eventData);
  • Unsubscribing from the event:
await context.action('oja/unsubscribe', 'topic', listener);

Subscribing as part of other action

context => {
    const listener = context.action(
        'oja/subscribe', 'topic', (eventType, eventData) => {
            console.log(eventData);
        }
    );
}

To trigger subscription, one needs to trigger the respective action.

Keywords

pubsub

FAQs

Package last updated on 10 Dec 2019

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