Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@pandino/event-admin

BlackBeltTechnology32EPL-2.00.8.31TypeScript support: included

Reference implementation of the Pandino Event Admin API

pandino, bundle, event, management, admin

readme

Event Admin

build-test license TypeScript

This is the reference implementation of the Pandino Event API.

Context

This package is part of the pandino-root monorepo. For detailed information about what is Pandino / how this package fits into the ecosystem, please consult with the related documentation(s).

Creating Events

Events consist of quite a lot of properties, therefore the easiest way to construct one is by utilizing the EventFactory. Sending the Event can be achieved by calling the postEvent() method on the obtained EventAdmin instance.

Every Event consists of a topic (string), and a properties object.

Please note, that Event delivery is fully async, and the order of delivery is not pre-defined!

It should be considered as a best practice to ensure that the properies objects is serializable. E.g.: JSON.stringify() and JSON.parse() compliant.

Example

import { EVENT_ADMIN_INTERFACE_KEY, EVENT_FACTORY_INTERFACE_KEY } from '@pandino/event-api';

export default class Activator {
  async start(context) {
    this.eventAdminReference = context.getServiceReference(EVENT_ADMIN_INTERFACE_KEY);
    this.eventAdmin = context.getService(this.eventAdminReference);
    this.eventFactoryReference = context.getServiceReference(EVENT_FACTORY_INTERFACE_KEY);
    this.eventFactory = context.getService(this.eventFactoryReference);

    // create the Event
    const event = eventFactory.build('@scope/app/TestTopic', {
      prop1: 'yayy',
    });

    // send the Event
    this.eventAdmin.postEvent(event);
  }

  async stop(context) {
    context.ungetService(this.eventFactoryReference);
    context.ungetService(this.eventAdminReference);
  }
}

Listening to Events

Any Service which implements the @pandino/pandino-event-admin/EventHandler interface and has the service property event.topics (either a single string, or an Array<string> can be provided as value) defined can listen to Pandino Events.

In order to narrow down unnecessary triggering of EventHandlers, an additional service property event.filter can be defined!

Example

import { EVENT_HANDLER_INTERFACE_KEY, EVENT_TOPIC } from '@pandino/event-api';

export default class BundleActivator {
  async start(context) {
    this.registration = context.registerService(EVENT_HANDLER_INTERFACE_KEY, new TestTopicEventHandler(), {
      [EVENT_TOPIC]: '@scope/app/TestTopic'
    });
  }

  async stop(context) {
    context.unregisterService(this.registration);
  }
}

class TestTopicEventHandler {
  handleEvent(event) {
    console.log(event.getTopic());
    console.log(event.getPropertyNames());
    // ...
  }
}

Topics

Topics should be unique. The recommended way of setting them up to prefix every topic with an actual package scope, and make them as explicit as possible. Topic segment separator MUST be the / character. Topics CAN start with the @ character to mirror NPM-style scopes, but it is not mandatory.

Topic matching

Matching by default is done in an case-sensitive, as-is manner for plain topics, e.g.: @scope/package/topic1. In this case, only exact matches will trigger listeners.

However there are two reserved keys which you can use as suffixes to loosen up the matching:

  • .: matches for exactly one additional segment, no more, no less
  • *: matches for at least one additional segment, no less

Examples

In the Table below headers represent topics, and the first column the test cases:

| | @pandino/pandino/Foo | @pandino/pandino. | @pandino/pandino* | |---------------------------|----------------------|-------------------|-------------------| | @pandino/pandino/Foo | true | true | true | | @pandino/pandino/Bar | false | true | true | | @pandino/pandino/Foo$1 | false | true | true | | @pandino/pandino/Foo/Test | false | false | true | | @pandino/pandino | false | false | false |

License

Eclipse Public License - v 2.0

changelog

(2023-11-11)

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

0.8.30 (2023-11-11)

Note: Version bump only for package pandino-root

0.8.29 (2023-07-24)

Note: Version bump only for package pandino-root

0.8.28 (2023-07-24)

Note: Version bump only for package pandino-root

0.8.27 (2023-03-06)

Bug Fixes

  • react-hooks: add missing service listener cleanup (4783a4c)

0.8.26 (2023-03-01)

Bug Fixes

  • react-hooks: improve service and bundle lifecycle handling (a722ed9)

0.8.25 (2023-02-28)

Bug Fixes

  • pandino: fix root cause of initial service tracking issues (7e2248d)

0.8.24 (2023-02-27)

Bug Fixes

  • react-hooks: fix service tracker initial service detection (154f0d6)

0.8.23 (2023-02-24)

Features

  • react-hooks: introduce react hooks (#54) (6e01203)

0.8.21 (2023-02-17)

Bug Fixes

  • improve bundle loading stability, fix type exports (41a9508)

0.8.20 (2023-02-15)

Bug Fixes

  • pandino: fix bundle lifecycle issues for bundle chains (be046a2)

0.8.18 (2022-10-06)

Features

  • pandino: Add support for ActivatorResolvers (c6b81e3)

0.8.16 (2022-09-08)

Features

  • webpack-plugin-generate-manifest: add manifest generator for Webpack (3fe7dc8)

0.8.13 (2022-09-02)

Features

  • loader-configuration-dom: introduce default DOM-based bundler loader (ad6756d)
  • loader-configuration-nodejs: introduce default NodeJS-based bundler loader (7e7ded7)

0.8.1 (2022-08-25)

Bug Fixes

  • fix types section of package.json files (8c7fd71)

0.8.0 (2022-08-23)

Bug Fixes

  • BundleContext API (389ce0a)
  • Configuration admin event handling (252aee7)
  • configuration cache delete (83cad32)
  • configuration cache delete #2 (780933d)
  • Configuration equals method [ci skip] (a98a77b)
  • Configuration Manager lifecycle (6fcc24f)
  • configuration manager not updating configurations properly (d03b7cb)
  • example projects (00ebe60)
  • fix rollup plugin pandino react externalize to output all sources (3f747f4)
  • misleading NodeJS JavaScript example setup (5b21fb8)
  • Pandino now compatible with NodeJs v14.x again (19e3f10)
  • pandino typedef mapping (67cb3d9)
  • pandino-configuration-management: fix required capability (2c19cab)
  • pandino-mission-control-dom: fix typo for bundle state (96685d4)
  • pandino: fix bundle lifecycle, bundles not ending up in uninstalled state (16af965)
  • pandino: fix inactive bundles not blocking starting of dependent bundles (f10f26e)
  • persistence manager interface key (ce78fe6)
  • pokedex: fix bundle requirements (f7cfbf2)
  • prettier script missing files (a1746e0)
  • provide capability for memory-based persistence manager (ae107eb)
  • react-dom: pandino-react-dom bundle, missing capability-provide for example (78316b4)
  • rollup-plugin-generate-manifest: remove redundant license entry from manifest (acd08b9)
  • service loading error (2135fe5)
  • test debugger breakpoint issues (f8f0343)

Features

  • add BundleTracker and ServiceTracker functionality (3b4edc2)
  • add complex React example project, fix bugs, enhance rollup plugin (3a214e5)
  • add ConfigAdmin and EventAdmin APIs (735dbe7)
  • add EventAdmin implementation (9a5b597)
  • add EventAdmin post functionality with tests (c7bc6d5)
  • add experimental nodejs installer bundle (1aeff82)
  • add experimental Rollup plugin to support externalized React Component projects (d71740f)
  • add hasObjectClass API to ServiceReference (62af710)
  • add in-memory implementation of the persistence manager api (f611c6b)
  • add Log API (3a749d9)
  • add more examples [skip ci] (2a28b6a)
  • add node cjs example project (b8c7da2)
  • add Persistence Manager API (4334373)
  • add placeholder event admin implementation package (f56a762)
  • add rollup-plugin-generate-manifest plugin (679ee49)
  • add service listener filter support (6505a59)
  • add targeted pid without support (9a7771f)
  • bundle-installer-nodejs: update Bundle (cea16d3)
  • ConfigAdmin features and added tests (a43873b)
  • finalize configuration manager, with added example project (80160f5)
  • finalize simple nodejs example project (20a3b26)
  • implement BundleContext listeners support (dbe0f0b)
  • implement BundleContext service support (1bf7446)
  • improve Bundle update handling (fad4239)
  • improve EventAdmin, also fix it not being able to react to Service registrations (9c5a83f)
  • init configuration management (2669ec4)
  • integrating persistence manager with configuration manager (0494dd9)
  • introduce Config Admin (f3f815a)
  • NodeJS support and refine public APIs (fa2f53f)
  • pandino-mission-control-dom: add bundle list with actions (09fa985)
  • pandino-mission-control-dom: add initial version of Pandino Mission Control DOM (9d8a96d)
  • pandino-mui-core: add initial version of mui wrapper bundle (3a30c07)
  • pandino-prop-types: add prop-types wrapping bundle (22d1a8d)
  • pandino-react-dom: add missing default export for React, update typedefs (3d6055a)
  • pandino-react-router-dom: add pandino-react-router-dom bundle to extras (29e0ab7)
  • pandino: add bundle tracker (cda2032)
  • pandino: add Service Tracker (f46e63d)
  • pandino: expose ServiceTracker and BundleTracker APIs via BundleContext (89c12a6)
  • pandino: prototype service support (71f9c2b)
  • persistence manager - localstorage implementation (9f00112)
  • provide explicit, separate cjs and esm bundles for pandino (dbd8ae6)
  • react-dom: initial implementation of React DOM Bundle with example project (0b2daca)
  • rollup-plugin-generate-manifest: add more license handling options (2a8209d)
  • support targeted pids in CM (a2b5864)
  • update examples, add NodeJS example project (c3297a2)
  • update pandino-react-dom to support React 18 (7162164)
  • update react component proxy example project (85fe048)
  • update react-pandino example project to include the new react-router-dom bundle (c00c911)
  • update react-pandino example project with initial version of wrapped MUI bundle (f8b63b6)