@runnel/metric-plugin
TypeScript icon, indicating that this package has built-in type declarations

0.1.4 • Public • Published

@runnel/metric-plugin

This library is designed for Runnel. Please visit our documentation and learn more.

Usage

const { plugin, subscribe } = createPlugin(deepEqual);
const eventBus = createEventBus({
  deepEqual,
  payloadValidator,
  pluginMap: new Map([[window, [metricPlugin]]]), // To observe the window. If the `scope` is smaller than the specified plugin scope, the specified plugin will not function.
});

...

// Example with React.useState
const [metrics, setMetrics] = useState();
subscribe(setMetrics);

Output Examples

Case 1

  • topic1 with schema { "type": "number" }.
  • No subscribers.
  • One publish event with payload 100.
{
  "topic1": {
    "onCreatePublish": 1,
    "publish": [100],
    "onCreateSubscribe": 0,
    "subscribe": [],
    "schema": { "type": "number" }
  }
}

Case 2

  • topic2 with schema { "type": "string" }.
  • One subscriber.
  • No publish events.
{
  "topic2": {
    "onCreatePublish": 0,
    "publish": [],
    "onCreateSubscribe": 1,
    "subscribe": [],
    "schema": { "type": "string" }
  }
}

Dependencies (0)

    Dev Dependencies (4)

    Package Sidebar

    Install

    npm i @runnel/metric-plugin

    Weekly Downloads

    9

    Version

    0.1.4

    License

    MIT

    Unpacked Size

    6.58 kB

    Total Files

    7

    Last publish

    Collaborators

    • wataru