Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

custom-event-ts

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

custom-event-ts

[![Build Status](https://travis-ci.org/boycgit/custom-event-ts.svg?branch=master)](https://travis-ci.org/boycgit/custom-event-ts) [![Coverage Status](https://coveralls.io/repos/github/boycgit/custom-event-ts/badge.svg?branch=master)](https://coveralls.io/

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

custom-event-ts

Build Status Coverage Status MIT Licence npm version

A polyfill for CustomEvents on IE8+ written in Typescript

  • written in Typescript
  • fully tested
  • auto polyfill CustomEvent when using
  • offer GlobalEvent for easy use

一旦引用该组件,就会自动对 CustomEvent 进行 polyfill,同时提供组件 GlobalEvent 对象(默认导出)方便在全局进行自定义事件的订阅

参考文档

实现

教程

Installation

Node.js / Browserify

npm install custom-event-ts --save
import GlobalEvent from "custom-event-ts";

// or
var GlobalEvent = require('custom-event-ts');

// Listen event 'SAY_HELLO'
GlobalEvent.on('SAY_HELLO', (data) => {
    console.log(data.detail) // { name: 'John' }
})

// Dispatch event 'SAY_HELLO' with data
GlobalEvent.dispatch('SAY_HELLO', { name: 'John' })

// Remove event listener
GlobalEvent.off('SAY_HELLO')

Global object

在页面中可以直接使用打包好的文件:

<script src="./dist/index.umd.min.js"></script>

通过 window.GlobaEvent 获取功能对象。

Build & test

npm run build
npm test
npm run doc

then open the generated out/index.html file in your browser.

License

MIT.

FAQs

Package last updated on 10 Aug 2019

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc