aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorEduardo Sebastian <[email protected]>2017-01-15 21:30:55 +0100
committerEduardo Sebastian <[email protected]>2017-01-15 21:30:55 +0100
commit76c1d963871daf8d126309fb4854262618f33827 (patch)
tree509ecffe9149a1d25a996ec0a9dc100a588d6d8b /README.md
parent656c8c381a222294aaebf520ef70a3d449687b9f (diff)
Include sample usage in readme
Diffstat (limited to 'README.md')
-rw-r--r--README.md19
1 files changed, 19 insertions, 0 deletions
diff --git a/README.md b/README.md
index 2b6974e..8978dae 100644
--- a/README.md
+++ b/README.md
@@ -52,3 +52,22 @@ If present, `"*"` handlers are invoked prior to type-matched handlers.
- `type` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The event type to invoke
- `event` **\[Any]** An event object, passed to each handler
+
+* * *
+
+## Sample usage
+
+```es6
+import mitt from 'mitt'
+
+let emitter = mitt()
+
+// listen to an event
+emitter.on('foo', e => console.log('foo', e) )
+
+// listen to all events
+emitter.on('*', (type, e) => console.log(type, e) )
+
+// fire an event
+emitter.emit('foo', { a: 'b' })
+```