npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

dom-di

v0.1.5

Published

Dependency injection via DOM

Readme

DOM-DI Project

Site of project: http://dom-di.org

NPM : dom-di

GitHub: https://github.com/wolf-off/dom-di

Purpose

Target of DOM-DI is support your frontend by low coupling. It allow you to implement Interaction and Dependency Injection between your component via DOM. There are two main dirrection of usage:

  1. In Web-components
  2. When you works with differents frameworks in one application (Angulars/React/Vue)

Anyway It allows you work in Micro Frontend approach

Install

npm install dom-di

All you need is in src folder

Add

  <script src="../src/diContainer.js"></script>
  <script src="../src/diContainerMixin.js"></script>
  <script src="../src/diObjectMixin.js"></script>

Send data between controls

  1. Inherit both your control from diObjectMixin (/src/diObjectMixin.js)
class MyControl extends diContainerMixin(HTMLElement) 

See Frameworks section for framefork's specific information

  1. call diSubscribe to receive data
    this.diSubscribe((data) => {
        //use your data
    });
  1. call diSend to send data
    this.diSend(data);

Simple Dependency Injection

Provide Control

  1. Inherit your control from diObjectMixin (/src/diObjectMixin.js)
  2. Add
      this.typeName = 'control-to-provide';

Receive Control

  1. Inherit your control from diObjectMixin (/src/diObjectMixin.js)
  2. Add
      this.dependencies = ['control-to-provide'];
      this.diReady = (control) => {
        // add your code
      }

If you have done well, diReady will be called with the control in parameters

Common usage example

Control can be provided and receved simulteniously. Control can contain several dependencies

      this.typeName = 'c-control';
      this.dependencies = ['a-control', 'b-control'];
      this.diReady = (a, b) => {
        this.a=a;
        this.b=b;
      }

Localize conversation

There are two way to localize conversation between your components:

  1. Add dom-di-container (/src/Controls/Container.html) Sure that all partisipants of conversation is child of the control ( may be not direct)
  2. Or inherit one parent control from diContainerMixin (/src/diContainerMixin.js)

It allows you to not share events/injection outside container

Frameworks

To use dom-di you should
  1. Inherit your component from diObjectMixin (/src/diObjectMixin.js)

  2. Implement dispatchEvent method to send events to DOM

    It depends on frameworks:

  3. AngularJS

  4. Angular

  5. React

  6. Vue

    If your control is some framework's control, realize dispatchEvent method to send events to DOM

AngularJS

myCtr = function ($element) {
  return new (diObjectMixin(function () {

    .
    .
    .

    this.dispatchEvent = (event) => {
      $element[0].dispatchEvent(event);
    }
  }))();
};

Angular

export class AppComponent extends diObjectMixin(Object) {

  constructor(private elRef: ElementRef) {
    super();
  }

  .
  .
  .

  dispatchEvent(event) {
    this.elRef.nativeElement.dispatchEvent(event);
  }
}

React

..not complited in case of low react knoledge, but it is works for me
class Hello extends diObjectMixinBabel(React.Component) {
    .
    .
    .
  dispatchEvent(event) {
    if (this.nv) {
      this.nv.dispatchEvent(event);
    } else {
      if (!this.nvQueue) {
        this.nvQueue = [];
      }
      this.nvQueue.push(event);
    }
  }

  componentDidMount() {
    if (this.nvQueue) {
      this.nvQueue.forEach(e => this.dispatchEvent(e));
      this.nvQueue = null;
    }
  }    
}

Vue

..not complited in case of low vue knoledge, but it is possible