I am developing a new library above amqp.node (amqplib), basically we dont need all the RabbitMQ functionality. So, I am creating a simple library that facilitates the usage specifically for our project.
This new library will return Promises. So, for example, subscribing to a queue will return a Promise about Ok and Error. But, what should I do with later issues? Disconnect, reconnect, Queue deleted, etc, etc? This will happen after the promise has been resolve. Should my new class emit his own errors? Is this a good way of working with promises?
Promises are one shot devices. So, they are only the right design tool for a one time state transition. Once they've been resolved or rejected, they are locked into that state. After that, you either have to have new promises for new operations or promises aren't really the right scheme and you'd rather have something like event notification.
So, if you can have a disconnect, then a reconnect, then a disconnect, etc... you'll either have to create a new promise for each state transition or promises aren't really the simplest implementation and what you really want is just an ability to subscribe listeners to various events (derive from an eventEmitter and emit interesting events that others can listen to).
I don't claim to understand exactly what you're trying to build, but several parts of your description sound like maybe you want more of an event notification scheme for much of your project instead of promises.
FYI, here are some interesting articles on the different notification schemes:
Callbacks, Promises, Signals and Events
JavaScript Asynchronous Architectures: Events vs. Promises
Event Emitter, Pub Sub or Deferred Promises … which should you choose?
I found a nice script to highlight html table rows and it works fine : http://nerds-central.blogspot.ca/2006/12/selectable-table-rows-with-html-and.html I changed the onclick event for onmouseover ...
I found a nice script to highlight html table rows and it works fine : http://nerds-central.blogspot.ca/2006/12/selectable-table-rows-with-html-and.html I changed the onclick event for onmouseover ...
I have several divs as follows in my HTML code: <div>#558C89</div> and I want the background of the every div to have the value it holds. I came up with a script that does that, but only ...
I have several divs as follows in my HTML code: <div>#558C89</div> and I want the background of the every div to have the value it holds. I came up with a script that does that, but only ...
I'm attempting to scrape a <script> tag from a set of webpages using Simple HTML Dom. At first, I was scraping it by providing the numerical order of the tag I needed: $script = $html->find('...
I'm attempting to scrape a <script> tag from a set of webpages using Simple HTML Dom. At first, I was scraping it by providing the numerical order of the tag I needed: $script = $html->find('...
I will try to be as specific as I can. So I need to create a selector that filters the options. I have: types of cars The places where you can drive those cars. So for example you would select > ...
I will try to be as specific as I can. So I need to create a selector that filters the options. I have: types of cars The places where you can drive those cars. So for example you would select > ...