11<p align =" center " >
2- <img src =" https://i.imgur.com/BqsX9NT.png " width =" 256 " height =" 256 " alt =" mitt " >
3- <br >
4- <b >Mitt</b >: tiny 200b functional event emitter / pubsub.
2+ <img src =" https://i.imgur.com/BqsX9NT.png " width =" 300 " height =" 300 " alt =" mitt " >
53 <br >
64 <a href =" https://www.npmjs.org/package/mitt " ><img src =" https://img.shields.io/npm/v/mitt.svg?style=flat " alt =" npm " ></a > <a href =" https://travis-ci.org/developit/mitt " ><img src =" https://travis-ci.org/developit/mitt.svg?branch=master " alt =" travis " ></a > <a href =" https://david-dm.org/developit/mitt " ><img src =" https://david-dm.org/developit/mitt/status.svg " alt =" dependencies Status " ></a >
75</p >
86
9- ## Why Mitt?
7+ # Mitt
8+
9+ > Tiny 200b functional event emitter / pubsub.
1010
1111- ** Microscopic:** weighs less than 200 bytes gzipped
1212- ** Useful:** a wildcard ` "*" ` event type listens to all events
1313- ** Familiar:** same names & ideas as [ Node's EventEmitter] ( https://nodejs.org/api/events.html#events_class_eventemitter )
1414- ** Functional:** methods don't rely on ` this `
1515- ** Great Name:** somehow [ mitt] ( https://npm.im/mitt ) wasn't taken
1616
17- > Mitt was made for the browser, but works in any JavaScript runtime. It has no dependencies and supports IE9+.
17+ Mitt was made for the browser, but works in any JavaScript runtime. It has no dependencies and supports IE9+.
1818
19- ## Examples & Demos
19+ ## Table of Contents
20+ - [ Install] ( #install )
21+ - [ Usage] ( #usage )
22+ - [ Examples & Demos] ( #examples--demos )
23+ - [ API] ( #api )
24+ - [ Contribute] ( #contribute )
25+ - [ License] ( #license )
2026
21- <a href =" http://codepen.io/developit/pen/rjMEwW?editors=0110 " >
22- <b >Preact + Mitt Codepen Demo</b >
23- <br >
24- <img src =" https://i.imgur.com/CjBgOfJ.png " width =" 278 " alt =" preact + mitt preview " >
25- </a >
27+ ## Install
2628
27- * * *
29+ This project uses [ node ] ( http://nodejs.org ) and [ npm ] ( https://npmjs.com ) . Go check them out if you don't have them locally installed.
2830
29- ## Usage
31+ ``` sh
32+ $ npm install --save mitt
33+ ```
34+
35+ Then with a module bundler like [ rollup] ( http://rollupjs.org/ ) or [ webpack] ( https://webpack.js.org/ ) , use as you would anything else:
36+
37+ ``` javascript
38+ // using ES6 modules
39+ import mitt from ' mitt'
40+
41+ // using CommonJS modules
42+ var mitt = require (' mitt' )
43+ ```
44+
45+ The [ UMD] ( https://github.com/umdjs/umd ) build is also available on [ unpkg] ( https://unpkg.com ) :
3046
31- After installing via ` npm install --save mitt ` :
47+ ``` html
48+ <script src =" https://unpkg.com/mitt/dist/mitt.umd.js" ></script >
49+ ```
50+ You can find the library on ` window.mitt ` .
51+
52+ ## Usage
3253
3354``` js
3455import mitt from ' mitt'
@@ -50,15 +71,21 @@ emitter.on('foo', onFoo) // listen
5071emitter .off (' foo' , onFoo) // unlisten
5172```
5273
53- * * *
74+ ## Examples & Demos
75+
76+ <a href =" http://codepen.io/developit/pen/rjMEwW?editors=0110 " >
77+ <b >Preact + Mitt Codepen Demo</b >
78+ <br >
79+ <img src =" https://i.imgur.com/CjBgOfJ.png " width =" 278 " alt =" preact + mitt preview " >
80+ </a >
5481
5582## API
5683
5784### mitt
5885
5986Mitt: Tiny (~ 200b) functional event emitter / pubsub.
6087
61- Returns ** Mitt**
88+ Returns ** Mitt**
6289
6390#### on
6491
@@ -87,3 +114,28 @@ If present, `"*"` handlers are invoked prior to type-matched handlers.
87114
88115- ` type ` ** [ String] ( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String ) ** The event type to invoke
89116- ` event ` ** \[ Any] ** An event object, passed to each handler
117+
118+ ## Contribute
119+ First off, thanks for taking the time to contribute!
120+ Now, take a moment to be sure your contributions make sense to everyone else.
121+
122+ ### Reporting Issues
123+ Found a problem? Want a new feature? First of all see if your issue or idea has [ already been reported] ( ../../issues ) .
124+ If don't, just open a [ new clear and descriptive issue] ( ../../issues/new ) .
125+
126+ ### Submitting pull requests
127+ Pull requests are the greatest contributions, so be sure they are focused in scope, and do avoid unrelated commits.
128+
129+ - Fork it!
130+ - Clone your fork: ` git clone https://github.com/<your-username>/mitt `
131+ - Navigate to the newly cloned directory: ` cd mitt `
132+ - Create a new branch for the new feature: ` git checkout -b my-new-feature `
133+ - Install the tools necessary for development: ` npm install `
134+ - Make your changes.
135+ - Commit your changes: ` git commit -am 'Add some feature' `
136+ - Push to the branch: ` git push origin my-new-feature `
137+ - Submit a pull request with full remarks documenting your changes.
138+
139+ ## License
140+
141+ [ MIT License] ( LICENSE.md ) © ; [ Jason Miller] ( https://jasonformat.com/ )
0 commit comments