W3C home > Mailing lists > Public > public-webapps@w3.org > April to June 2014

RE: Progress on Push API

From: Domenic Denicola <domenic@domenicdenicola.com>
Date: Fri, 2 May 2014 15:17:53 +0000
To: John Mellor <johnme@google.com>, Martin Thomson <martin.thomson@gmail.com>
CC: Jonas Sicking <jonas@sicking.cc>, EDUARDO FULLEA CARRERA <efc@tid.es>, public-webapps <public-webapps@w3.org>
Message-ID: <1399043874195.78116@domenicdenicola.com>
Regarding promise idiomaticness, the two proposals I've seen that look most reasonable would be:

- isRegistered() + register(). But, this doesn't allow notification that you need to re-register, from what I can tell.
- A variant on registrationNeeded, where---since it can return a different promise each time---it becomes a method, named e.g. waitForRegistrationNeeded() or whenRegistrationNeeded().

The former is a very typical async-function-call use of promises. The latter is the notification-of-state-transition use of promises [1], which is a bit less typical, but is often convenient---especially, as Jonas notes, when you would want to find out even after the fact.

Also, be sure to only use rejections for exceptional situations [2]. It wasn't clear in your message, John, but you seemed to be proposing that isRegistered() reject when not registered? That would be a promise antipattern, akin to a synchronous function called isRegistered() throwing an exception to signal non-registration.

[1]: https://github.com/w3ctag/promises-guide/issues/25
[2]: https://github.com/w3ctag/promises-guide#rejections-should-be-used-for-exceptional-situations

Received on Friday, 2 May 2014 15:18:25 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 18:14:24 UTC