+
Skip to content

Yukiniro/miis

Repository files navigation

miis

NPM npm

The miis is a tiny functional event subscriber and dispatcher.

Install

This project need node and npm.

npm install miis --save

or

pnpm add miis --save

Useage

import miis from 'miis';

miis.subscribe("a", (...args) => {
  console.log('a event call'); // a event call
  console.log(...args); /// 1, 2, 3
});
miis.dispatch("a", 1, 2, 3);

You could unsubscribe the event lisenter with the result of subscribe.

import miis from 'miis';

const unsubscribe = miis.subscribe("a", () => {
  console.log('a event call');
});
unsubscribe();

miis.dispatch("a"); // not work

API

subscirbe

Register an event listenter for the given name.

Params

  • eventName string | symbol Name of event to listen for.
  • listenter Function Function to call in response to given event

Returns

  • unsubscribe Function Function to remove the listenter.

dispatch

Invoke all handlers for the given name.

  • eventName string | symbol Name of event to invoke for.

About

👀 A tiny functional event subscriber and dispatcher.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载