Skip to content

Commit

Permalink
feat: add readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Yukiniro committed Oct 16, 2022
1 parent a42f1a1 commit a704991
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 13 deletions.
70 changes: 58 additions & 12 deletions README.md
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.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "miis",
"version": "0.0.1",
"version": "1.0.0",
"description": "Tiny functional event subscriber and dispatcher.",
"main": "index.ts",
"scripts": {
Expand Down

0 comments on commit a704991

Please sign in to comment.