You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@saber2pr/event

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@saber2pr/event

Subscribe/Publish

0.1.1
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

@saber2pr/event

npm

min-size:[1.01 kb]

Subscribe/Publish

npm install @saber2pr/event

API

subscribe

参数: subscribe(eventName, callback)

eventName可设置为*,表示订阅所有消息(拦截器)

subscribe('test', data => console.log(data))

dispatch

参数:dispatch(eventName, data)

  • eventName 事件名
  • data 消息数据

eventName可设置为*,表示发布公共消息(观测者)

dispatch('test', 233)

For Typescript

createAction

参数 createAction<EventNameType, DataType>

type SayHello = createAction<'hello', string>
subscribe<SayHello>('hello', data => console.log(data, '1'))
subscribe<SayHello>('hello', data => console.log(data, '2'))()
subscribe<SayHello>('hello', data => console.log(data, '3'))

dispatch<SayHello>('hello', 'how are you?')

Keywords

event

FAQs

Package last updated on 05 May 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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.