Skip to content
Myr

Expose `all` property

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Relates to #70 #72 #102

authored by Jakob Linskeseder · committed by Jakob Linskeseder · parent 5959175 · Browse files · 3 files+41 added−15 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+41 added−15 removed

  • tests:+8 added−0 removed
  • other:+33 added−15 removed

3 files+41 added−15 removed

modified:src/index.ts+7 added
modified:test/index.js+8 added
28 unmodified lines
29 events = new Map();30 inst = mitt(events);31 });3233 describe('properties', () => {34 it('should expose the event handler map', () => {35 expect(inst)36 .to.have.property('all')37 .that.is.a('map');38 });39 });4041 describe('on()', () => {42 it('should be a function', () => {43 expect(inst)44 .to.have.property('on')
146 unmodified lines
modified:README.md+26 added-15 removed
67 unmodified lines
6869// fire an event70emitter.emit('foo', { a: 'b' })7172// clearing all events73emitter.all.clear()7475// working with handler references:76function onFoo() {}77emitter.on('foo', onFoo) // listen78emitter.off('foo', onFoo) // unlisten
22 unmodified lines
101102#### Table of Contents103104- [mitt](#mitt)102- [on](#on)105- [emit](#emit)106 - [Properties](#properties)107- [emit](#emit-1)108 - [Parameters](#parameters)104- [off](#off)109- [on](#on)110 - [Parameters](#parameters-1)106- [emit](#emit)111- [off](#off)112 - [Parameters](#parameters-2)113114### mitt115116Mitt: Tiny (~200b) functional event emitter / pubsub.117118Returns **Mitt** 119120### emit121122#### Properties123124- `all` **EventHandlerMap** Contains all registered event handlers.125126### emit127128Invoke all handlers for the given type.129If present, `"*"` handlers are invoked after type-matched handlers.130131Note: Manually firing "\*" handlers is not supported.132133#### Parameters134135- `type` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) \| [symbol](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol))** The event type to invoke136- `evt` **Any?** Any value (object is recommended and powerful), passed to each handler137138### on139140Register an event handler for the given type.141
10 unmodified lines
152153- `type` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) \| [symbol](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol))** Type of event to unregister `handler` from, or `"*"`154- `handler` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** Handler function to remove155133### emit134135Invoke all handlers for the given type.136If present, `"*"` handlers are invoked after type-matched handlers.137138Note: Manually firing "\*" handlers is not supported.139140#### Parameters141142- `type` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) \| [symbol](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol))** The event type to invoke143- `evt` **Any?** Any value (object is recommended and powerful), passed to each handler144156## Contribute157158First off, thanks for taking the time to contribute!159Now, take a moment to be sure your contributions make sense to everyone else.
23 unmodified lines