-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
59 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,65 @@ | ||
# ssprojet | ||
# miis | ||
|
||
![NPM](https://img.shields.io/npm/l/ssprojet?color=blue&style=flat-square) ![npm](https://img.shields.io/npm/v/ssprojet?color=blue&style=flat-square) | ||
![NPM](https://img.shields.io/npm/l/miis?color=blue&style=flat-square) ![npm](https://img.shields.io/npm/v/miis?color=blue&style=flat-square) | ||
|
||
The `ssprojet` is a template to start a simple project. | ||
> The `miis` is a tiny functional event subscriber and dispatcher. | ||
## Features | ||
## Install | ||
|
||
- `pnpm` - package manager | ||
- `vitest` - test library | ||
- `docusaurus` - document library | ||
- `prettier` - code style formate | ||
- `eslint` - code quality | ||
This project need node and npm. | ||
|
||
## How to use | ||
```shell | ||
npm install miis --save | ||
``` | ||
|
||
You could use `degit Yukiniro/ssprojet your-project-name` to create a project. | ||
or | ||
|
||
If you have no `degit`. Please install it by `npm install -g degit`. | ||
```shell | ||
pnpm add miis --save | ||
``` | ||
|
||
## Useage | ||
|
||
```javascript | ||
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. | ||
|
||
```javascript | ||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters