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 🙏

© 2024 – Pkg Stats / Ryan Hefner

event-bus-webcomponent

v1.0.0-2

Published

Stencil Component Starter

Downloads

3

Readme

Event Bus Webcomponent

Original Stencil Readme: ./stencil-readme.md

This webcomponent is intended as dom-based event bus with TypeScript save events.

Reason

Exchanging messages between angular elements (angular custom elements wit @angular/elements package) and their angular host applications is suprisingly hard.

Ideas and their shortcommings:

  • Using the angular injector from host app in angular element to exchange services:
    not easy/impossible, since an angular custom element project does not have access to the injector of the app where the webcomp will be running in.
  • Using any third party javascript event bus library:
    • can only act on distinct strings on the event bus, not on on typescript types (which would be nice for typed payloads in typescript!)
    • do mostly not have any typescript typing for their own (for the third-party event bus library)
  • Using a class with rxJS Subject:
    Fails due to module scoping of Webpack. If you try to pass an imaginary 'EventBus' object from the main Angular app to an angular elements webcomponent, the events that you emit in the host app can't be seen in the angular elements webcomponent
  • Putting the imaginary 'EventBus' class into a global wariable (like window.EventBus):
    This feels not ok, since it would pollute the global namespace again

=> My solution:

Write a custom html element called: event-bus-webcomponent, which can be queried using document.getElementByName, document.querySelector, etc. It then provides some methods, which can be called from outside, which basically is the same as having a global variable now. This would also allow the user to provide multiple distinct event busses by instantiating multiple of these elements on the page with different id-attributes, for example.

Attributions

  • Base system idea: https://www.bennadel.com/blog/3518-trying-to-create-a-message-bus-using-an-rxjs-subject-in-angular-6-1-10.htm