Socket
Socket
Sign inDemoInstall

y-event

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    y-event

Event system


Version published
Weekly downloads
275
decreased by-42.71%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Intro

A event system could emit first, register later.
Or works as normal

Installation

npm i -D y-event
# or
yarn add --dev y-event

Usage

import event from 'y-event'

// emit first, register later
event.$always('event1')
event.$on('event1', () => {
  console.log('event1 works') // event1 works
})

// normal use
event.$on('event2', (...args) => {
  console.log('event2', ...args)
})
event.$emit('event2', 1, 2, 3) // event2, 1, 2, 3

// off
event.$off('event2')
event.$emit('event2') // nothing happens

// invoke once
event.$once('event3', () => {
  console.log('event3')
})
event.$emit('event3') // 'event 3'
event.$emit('event3')

License

MIT

Copyright (c) 2017-present, Yuchen Liu

FAQs

Last updated on 01 Dec 2017

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc