New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@yugu/subscribe

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@yugu/subscribe

使用`import Subscribe from "@yugu/subscribe"`导入类 通过`const pool = new Subscribe`创建发布订阅实例 该类实例可以通过`add`方式向订阅池中添加事件,`pool.add(fn)` 该类实例可以通过`remove`方式从订阅池中移除事件,`pool.remove(fn)` 该类实例可以通过`fire`方式触发订阅池中所有的函数,`pool.fire()` ```js <script type="module"> imp

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

Subscribe发布订阅类

使用import Subscribe from "@yugu/subscribe"导入类 通过const pool = new Subscribe创建发布订阅实例 该类实例可以通过add方式向订阅池中添加事件,pool.add(fn) 该类实例可以通过remove方式从订阅池中移除事件,pool.remove(fn) 该类实例可以通过fire方式触发订阅池中所有的函数,pool.fire()

<script type="module">
  import Subscribe from "@yugu/subscribe";
  const btn = document.querySelector(".submit");
  const pool = new Subscribe();
  const fn1 = () => {
    console.log(1);
  };
  const fn2 = () => {
    console.log(2);
    pool.remove(fn1);
  };
  const fn3 = () => {
    console.log(3);
  };
  const fn4 = () => {
    console.log(4);
  };
  pool.add(fn1);
  pool.add(fn2);
  pool.add(fn3);
  pool.add(fn4);
  btn.onclick = function (event) {
    pool.fire();
    console.log(pool);
  };
</script>

Keywords

发布订阅

FAQs

Package last updated on 10 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts