-
Notifications
You must be signed in to change notification settings - Fork 381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have not released any v2 version yet. So I think we can fix it everywhere.
95dab35
to
00b945c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very nice!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
advertiseAsync
function to theService
class 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
advertise
function 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.