On Tuesday, September 22, 2015 at 3:02:21 AM UTC-7, smaug wrote:
> That document is from 2015 ;)

Oh. Fun!

> The example in that chapter is "This property should return the same promise 
> every time it is retrieved, until the image moves backward from the 
> loaded state into the unloaded state. Once that occurs, a new promise is 
> created, representing the next transition to loaded."
> So a new promise would be created.

Oh, ok. So it's basically not the API I'm looking for :(

> Why not use events for that? There is nothing wrong with events , and 
> https://www.w3.org/2001/tag/doc/promises-guide#when-not-to-use

Events are missable. That means that writing async/lib code where you have to 
be ready to be executed at any point requires the following code:

1) Check if the target is in the fulfilled state
2) If yes, apply logic
3) Set up event listener

With a Promise its:

1) Set a promise on the target
and either:
2a) In the promise callback, set event listener, but only if it's not set yet
or:
2b) Set an event listener now, but guard against double executing when event 
listener and promise are fulfilled at the same time.

This sort of repeatable-promise, would reduce it to:
1) Set the repeatable promise on the target

Sounds like it would make much easier to write async code without logic for 
preventing race conditions.

Is there any other approach to that?
zb.
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to