- 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>
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