I'm sorry to say that this will not work because of the fundamental difference between the promise and the flow. You say that you are new to both, so let me give you a brief introduction to both.
Promises can be thought of as placeholders for some single value that may not have arrived yet. For example, some hypothetical getTweet() functions may work as follows:
getTweet() .then(function (tweet) {
But it will bring you just one tweet! To get another one, you have to call getTweet() again, with the new .then() . In fact, when working with promises, you have a guarantee that .then() calls its containing function only once!
Streams are continuous streams of data. You do not need to manually request tweets, and then another, and then another. You open the tap, and then it just continues until it finishes, or you stop it.
So, in general, you cannot promise a stream, because promises are for single values ββand streams for continuous data streams.
I assume you asked a question because you like the promise interface and want to use something similar for streams? Depending on what you are trying to achieve, there are different libraries that can improve work with streams. EventStream is one example. Let me know what you are planning, and I could give you an example.
source share