Skip to content

ps 0.0.1

Install from the command line:
Learn more about npm packages
$ npm install @anh-ld/ps@0.0.1
Install via package.json:
"@anh-ld/ps": "0.0.1"

About this version

PS

  • Pub/Sub JS library that's inspirated from mitt.
  • The project's goal is to practice building the pub/sub library from scratch.

Installation

Add .npmrc into project

@culee:registry=https://npm.pkg.github.com
npm install @culee/ps

Usage

import pubsub from './src'

const ps = pubsub()

const foo1 = e => console.log('foo1', e)
const foo2 = e => console.log('foo2', e)
const bar = e => console.log('bar', e)
const wildcard = e => console.log('*', e)

/* register event listener */
ps.on('foo', foo1);
ps.on('foo', foo2);
ps.on('bar', bar)

/* register wildcard event listener */
ps.on('*', wildcard)

/* fire an event */
ps.emit('foo', { a: 'b' })
ps.emit('bar')

/* clear specific event listener */
ps.off('foo', foo1)

/* clear all event listeners of specific event name */
ps.clear('foo')

/* clear all event listeners */
ps.clear()

Details

  • ps
  • @anh-ld anh-ld
  • about 2 years ago
  • 3 dependencies

Assets

  • ps-0.0.1.tgz

Download activity

  • Total downloads 0
  • Last 30 days 0
  • Last week 0
  • Today 0

Recent versions

View all