Closed nah0y closed 6 years ago
Is there to "resolve" a promise multiple times?
No, that kind of goes against the idea of a Promise, you should be using an event/callback or message pattern.
A promise: Try to do this for me, and then tell me when you've succeeded or failed. An event: Tell me whenever this happens, so I can react to it.
You should be using reactive extensions for that (rx), that's an implementation of asynchronous streaming.
Where a promise is an asynchronous delivery mechanism for a single result, rx is an asynchronous delivery mechanism for a continuous stream of results.
I recommend reading the book into to rx, is free online.
Thanks to both of you for your answers. That's what I thought (and I'm currently using event/callbacks), but thanks for the tip with rx!
Here's a link to the book: http://www.introtorx.com/
If you like it please buy it to support the author.
Also more generally you should google 'reactive programming'. It's a really interesting concept that a lot of people are experimenting with.
Yes, I see that a lot recently. I have to find some time to dig into it though :(
Hello again,
Is there to "resolve" a promise multiple times? Imagine I'm scanning for bluetooth devices, and I use a Promise for that. I would like to call .Resolve(deviceAddress) every time a new address is found for example, and start another process that will reject the promise after 60sc (to stop scanning). I don't think there's a way to do that, right?