aboutsummaryrefslogtreecommitdiff
path: root/example.js
diff options
context:
space:
mode:
authortunnckoCore <[email protected]>2017-01-17 18:36:02 +0200
committertunnckoCore <[email protected]>2017-01-17 18:36:02 +0200
commit8b4f2defd7fca02674a45d89900557a6a4b5e5c3 (patch)
treed997b0bcceb06ec5a17f9b30cca60d5dd1c549ee /example.js
parenta6190e91a68d35adffbeda2e92f92ec565557f89 (diff)
add example.js
Diffstat (limited to 'example.js')
-rw-r--r--example.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/example.js b/example.js
new file mode 100644
index 0000000..dac0983
--- /dev/null
+++ b/example.js
@@ -0,0 +1,20 @@
+'use strict'
+
+var mitt = require('./dist/mitt')
+var ee = mitt()
+
+ee
+ .on('*', (type, arg) => console.log('wildcard:', type, arg))
+ .on('foo', (one, two, three) => console.log('foo1:', one, two, three))
+ .on('foo', (one, two, three) => console.log('foo2:', one, two, three))
+ .on('bar', (arg) => console.log('bar:', arg))
+ .emit('foo', 1, 2, 3)
+ .emit('bar', 444)
+
+console.log(ee.all)
+
+var emitter = mitt()
+
+console.log(emitter.all) // => {}
+
+emitter.emit('foo', 777)