3.4.1 • Published 5 years ago

beatrix-events v3.4.1

Weekly downloads
-
License
ISC
Repository
-
Last release
5 years ago

beatrix-events

System for emitting and reacting to events using Beatrix / RabbitMQ

Events are optionally filtered using Sift

Sample usage

const Manager = require('beatrix-events');

Manager.connect({
  name: 'blah', // name of this application, for namespacing queues
  uri: 'amqp://guest:guest@localhost/' // would normally be passed based on environment settings
});

// listen for all types of people
Manager.on('colony.people', {
  persistent: true, // enqueue events of this type even when this consumer isnt alive
  filter: {age: {$gt: 30}} // only run the method for people over 20
}, async (person) => {
  if (person.name > 'Logan') {
    throw new Error('Run, Logan, Run')
  }
  return person.name + ' was eliminated for the greater good';
})

setInterval(() => {
  Manager.emit('colony.people', generateRandomPerson());
}, 1000);
3.4.1

5 years ago

3.4.0

5 years ago

3.0.2

6 years ago

3.0.1

6 years ago

3.0.0

7 years ago

2.3.2

7 years ago

2.3.1

7 years ago

2.3.0

7 years ago

2.2.1

7 years ago

2.2.0

7 years ago

2.0.0

7 years ago