1.1.9 • Published 8 years ago

eventory v1.1.9

Weekly downloads
1
License
MIT
Repository
github
Last release
8 years ago

Event Hub

Event Hub provides event pub/sub.

Features:

  • synchronized callback along all async handlers
  • support Promises (promit)
  • emission timeout
  • keys with placeholder
  • key-as-function
  • defered emitting (await for postponed addition of listener)

Implementation

  • written in JS6
  • no extra dependencies

API

class EventHub

   once(key, handler): ownerId
   
   on(key, handler, ownerId): ownerId
   
   offOwner(ownerId)
   
   off(keyPrefix)
   
   emit(key, {timeoutInSeconds:10, ...params}, [callback])
  
   promit(key, {...params}).then((after)=>{})

Example

var hub = new EventHub();

hub.on('api', (params, cb)=> cb(null, params));

hub.emit('api', params, callback);

hub.off('api');

See test/test.js for more use cases.

Repo

https://github.com/alitskevich/eventhub

Legal

The MIT License (MIT)

Copyright (c) 2015 Alex Litskevich

1.1.9

8 years ago

1.1.6

8 years ago

1.1.4

9 years ago

1.1.2

9 years ago

1.1.1

9 years ago

1.1.0

9 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago