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

@gmsoft/event-bus

v1.4.0

Published

gmsoft eventBus

Downloads

10

Readme

子应用和容器通信使用

/**
 * 创建或者从顶层窗口查找 eventBus
 * @param forceCreateNew 强制使用新的 eventBus, 否则尝试查找 top.eventBus
 * @param registerDefaultEvents 注册默认事件
 */
const createOrFindInTop = (
  forceCreateNew: boolean = false,
  registerDefaultEvents: boolean = true
) => eventBus
默认注册的事件
  /**
   * @param {string} data - 被注入的样式数据(css代码 | css文件链接)
   * @param {string} type - 注入的方式 style | link
   * injectCss: fn(data, type)
   */
  eventBus.on('inject.css', injectCss);

  /**
   * @param {string} src - 被注入的js文件链接
   * injectjs: fn(src) => Promise
   */
  eventBus.on('inject.js', injectJs);

  /**
   * store.set: fn(key, value)
   */
  eventBus.on('store.set', store.set.bind(store));

  /**
   * store.get: fn(key, defaultValue)
   */
  eventBus.on('store.get', store.get.bind(store));

  /**
   * store.remove: fn(key)
   */
  eventBus.on('store.remove', store.remove.bind(store));

  /**
   * store.clear: fn()
   */
  eventBus.on('store.clear', store.clear.bind(store));

  /**
   * 回到页面顶部(可以指定位置)
   * gotop: fn(position=0, isSmooth=true)
   */
  eventBus.on('page.gotop', gotop);

  /**
   * 页面打印, ie尝试使用打印插件
   */
  eventBus.on('page.print', print);

  /**
   * antd 的 Modal, 如何使用参见:
   * https://ant.design/components/modal-cn/#Modal.method()
   */
  eventBus.on('antd.Modal.info', Modal.info);
  eventBus.on('antd.Modal.success', Modal.success);
  eventBus.on('antd.Modal.error', Modal.error);
  eventBus.on('antd.Modal.warning', Modal.warning);
  eventBus.on('antd.Modal.confirm', Modal.confirm);
  eventBus.on('antd.Modal.destroyAll', Modal.destroyAll);

  /**
   * antd 的 message, 如何使用参见:
   * https://ant.design/components/message-cn/#API
   */
  eventBus.on('antd.message.info', message.info);
  eventBus.on('antd.message.success', message.success);
  eventBus.on('antd.message.error', message.error);
  eventBus.on('antd.message.warning', message.warning);
  eventBus.on('antd.message.loading', message.loading);
  eventBus.on('antd.message.destroy', message.destroy);

  /**
   * antd 的 message, 如何使用参见:
   * https://ant.design/components/notification-cn/#API
   */
  eventBus.on('antd.notification.info', notification.info);
  eventBus.on('antd.notification.success', notification.success);
  eventBus.on('antd.notification.error', notification.error);
  eventBus.on('antd.notification.warning', notification.warning);
  eventBus.on('antd.notification.open', notification.open);
  eventBus.on('antd.notification.close', notification.close);
  eventBus.on('antd.notification.destroy', notification.destroy);