Add advertiseAsync method to Service#698
Conversation
| if (this.isAdvertised) { | ||
| throw new Error('Cannot advertise the same Service twice!'); | ||
| } |
There was a problem hiding this comment.
I think we should move toward this behavior in all of the cases throughout the library where there's currently guard conditions that just early-return with no information. Users shouldn't be calling advertise multiple times on the same Service object, that's probably an issue with their code!
I don't want to break that in existing functions yet, but figured I'd do it here where we have a green field.
There was a problem hiding this comment.
We have not released any v2 version yet. So I think we can fix it everywhere.
95dab35 to
00b945c
Compare
MatthijsBurgh
left a comment
There was a problem hiding this comment.
Do we to add unadvertise functionality?
|
I believe the existing |
@EzraBrooks sounds like a good idea |
|
I'll merge this and open up a follow-up PR that fixes |
Public API Changes
Adds an
advertiseAsyncfunction to theServiceclass to allow Promise-returning functions as callbacks to services.Description
☝🏻
This is useful for cases where, like a feature I'm working on right now in my application, you want to wait to return a Service call until a different asynchronous operation completes. The original
advertisefunction is very limiting because it requires all operations undertaken by the Service server to be synchronous due to the design of asynchronicity in JavaScript disincentivizing synchronizing async closures into synchronous ones.