0

The common use of a promise/deferred implementation is to create a promise, then after some asynchronous event occurs, decide whether to resolve or reject the promise.

Of course, once a promise has been resolved or rejected, its state cannot be changed -- it has been fulfilled.

What I am wondering is if there is a concept sort of similar to promises, but a kind of scenario in which the state might go back and forth.

For example, say a particular service is available every 5 minutes for a period of 60 seconds.

Whenever the service is available, any requests are fulfilled (passed to it) immediately. Whenever the service is unavailable, requests are pending and added to a queue, and as soon as the service becomes available, all backed-up requests in the queue are sent and fulfilled.

I know this concept isn't a promise, but I was wondering if this is an actual named situation in programming, and if there are existing library implementations of it (particularly in Node.js).

Did that make sense? Does such a thing exist?

M Miller
  • 5,364
  • 9
  • 43
  • 65
  • 1
    possible duplicate of [What is *like* a promise but can resolve mutliple times?](http://stackoverflow.com/q/29958779/1048572) – Bergi Jul 06 '15 at 00:21
  • @Bergi maybe [*What is the inverse of a promise?*](http://stackoverflow.com/questions/26084439/what-is-the-inverse-of-a-promise) – Benjamin Gruenbaum Jul 06 '15 at 10:51
  • 1
    Also, lol, the guy who asked the question is called "M Miller". – Benjamin Gruenbaum Jul 06 '15 at 10:54
  • But yeah, in all seriousness - you probably want an observable. – Benjamin Gruenbaum Jul 06 '15 at 10:55
  • @BenjaminGruenbaum: Nah, my question about the inverse of a promise is asking for a thing that only changes it's state once only (that's why I haven't accepted your answer yet) – Bergi Jul 06 '15 at 11:47
  • @Bergi That is exactly what I was looking for! Should've looked more closely at similar search results, I wasn't sure if I was explaining it right. Thanks! – M Miller Jul 06 '15 at 14:58

0 Answers0