1.1.9 • Published 10 years ago

eventory v1.1.9

Weekly downloads
1
License
MIT
Repository
github
Last release
10 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

10 years ago

1.1.6

10 years ago

1.1.4

10 years ago

1.1.2

10 years ago

1.1.1

10 years ago

1.1.0

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago