News for hackers. Stuff that matters.
Re:Allora – Use promises on any JavaScript object by throwanem on Monday July 18, 2016 @07:44PM (#12118636)
It's not possible to fulfill a promise more than once, no.

But a Promise.all method, while outside the A+ spec, conventionally returns a promise for the resolution of all promises in the array passed as an argument; if all those promises are fulfilled, so will be the promise returned by .all, while if any of them is rejected, so will be the etc., etc.

So the browser example given in the Allora Github readme is perfectly reasonable. It's the exact same kind of thing you do when, for example, you need to await the completion of multiple separate HTTP requests in order to do something with all of their results. While, again, .all isn't part of the A+ standard, this is perfectly conventional and unremarkable behavior; not only is it unsurprising to see in a library like this one, it would be exceptional in its absence if it weren't there.

That said, I would be curious to see Allora compared with, for example, Bluebird's "promisifyAll" method, which appears to do much the same thing.

Re:Allora – Use promises on any JavaScript object by c-smile on Monday July 18, 2016 @08:21PM (#12118755)
So what does this

   thatWindow.setInterval(100).then( foo )
mean exactly? How many times the foo() will be called? And how to stop that interval?
Re:Allora – Use promises on any JavaScript object by gianlucaguarini on Tuesday July 19, 2016 @12:56AM (#12119791)
foo will be called only once (see my answer above). I am working on another script to achieve event streams using es6 generators let's keep in touch
Re:Allora – Use promises on any JavaScript object by egeozcan on Tuesday July 19, 2016 @07:44AM (#12121139)

    promisifiedWindow.setInterval(200).then(x => console.log("res:", x));
    -> Promise {[[PromiseStatus]]: "pending", [[PromiseValue]]: undefined}
    >> VM310:1 res: undefined
How do you cancel the interval?
Re:Allora – Use promises on any JavaScript object by gianlucaguarini on Tuesday July 19, 2016 @08:45AM (#12121380)
Ok with this it should be possible https://github.com/GianlucaGuarini/allora/pull/3
Re:Allora – Use promises on any JavaScript object by gianlucaguarini on Tuesday July 19, 2016 @07:51AM (#12121168)
At moment it's not possible and it does not make any sense to use a setInterval with a promise in return. But I will think about a simple solution to clear the timer functions