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
