1. dd-event
Simple event observer.
dd-event
Package: dd-event
Created by: dadajam4
Last modified: Thu, 28 Apr 2022 07:18:38 GMT
Version: 0.2.1
License: MIT
Downloads: 6
Repository: https://github.com/dadajam4/dd-ev

Install

npm install dd-event
yarn add dd-event

dd-event

This package has been moved to: https://www.npmjs.com/package/@dadajam4/ev

Simple Class basesd event observer.(With TypeScript type injection)

docs

Usage

Install package

npm install dd-event --save

In your code

 import DDEV from 'dd-ev';

const ev = new DDEV();
ev.on('someEvent', e => {
  console.log(e);
  // ---> 10
  // ---> { someKey: 'someValue' }
});
ev.emit('someEvent', 10);
ev.emit('someEvent', { someKey: 'someValue' });

// Extends Class
class SomeClass extends DDEV {}

TypeScript

 class SomeClass extends DDEV<{event1: string, event2: boolean}> {
  constructor() {
    super();
    this.emit('event1', 5); // ng
    this.emit('event1', 'string'); // ok
    this.on('event2', event => {
      const var1: string = event; // ng
      const var2: boolean = event; // ok
    });
  }
}

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin